🚀 Day 79 of #100DaysOfCode Solved LeetCode Problem #3634 – Minimum Removals to Balance Array ✅ This problem was a great example of how sorting + sliding window can turn a tricky constraint problem into a clean and efficient solution. The goal was to keep the largest valid subarray and remove the rest—simple idea, but execution matters. Key Takeaways: -> Sorting helps simplify balance conditions -> Sliding window is powerful for range-based constraints -> Maximizing what you keep is often better than counting what you remove -> Careful pointer movement avoids unnecessary recomputation Language: Java -> Runtime: 23 ms (Beats 100.00%) ⚡ -> Memory: 86.17 MB Consistency beats intensity. One solid problem every day. 💻🔥 #LeetCode #Java #SlidingWindow #TwoPointers #Arrays #ProblemSolving #100DaysOfCode
LeetCode 3634: Minimum Removals to Balance Array in Java
More Relevant Posts
-
Day 2/100 – LeetCode Challenge 🚀 Problem: #48 Rotate Image Difficulty: Medium Language: Java Approach: In-Place Rotation using Transpose + Row Reversal Time Complexity: O(n²) Space Complexity: O(1) 🔍 Key Insight: To rotate a matrix 90° clockwise without extra space: 1️⃣ First transpose the matrix (swap across diagonal). 2️⃣ Then reverse each row. This avoids creating a new matrix and satisfies the in-place constraint. 🧠 Solution Brief: Used nested loops to transpose the matrix by swapping arr[i][j] and arr[j][i]. Then reversed each row using two pointers (start and end). Combined both operations inside a rotate() method. Achieved full rotation with constant extra space. 📌 What I Learned: Matrix problems are more about pattern recognition than brute force. Understanding transformations (transpose + reverse) makes complex problems simple. Starting my 100 Days of LeetCode journey today 💪 Consistency > Motivation. #LeetCode #Day2 #100DaysOfCode #Java #DSA #Matrix #ProblemSolving #CodingJourney #MediumProblem
To view or add a comment, sign in
-
-
🚀 Day 85 of #100DaysOfCode Solved LeetCode Problem #3713 – Longest Balanced Substring I ✅ A classic string + frequency-based problem that rewards careful iteration and validation. The goal was to find the longest substring where all present characters appear the same number of times—simple idea, but requires disciplined checking. Key Takeaways: -> Brute-force with pruning can still pass when constraints allow -> Frequency arrays are powerful for substring analysis -> Early balance checks save unnecessary computation -> Always align solution strategy with input limits Language: Java -> Runtime: 83 ms (Beats 88.95%) ⚡ -> Memory: 47.29 MB Small wins matter. Staying consistent, one problem at a time. 💻🔥 #LeetCode #Java #Strings #ProblemSolving #Algorithms #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 81 of #100DaysOfCode Solved LeetCode Problem #110 – Balanced Binary Tree ✅ A classic tree problem that rewards thinking bottom-up. Instead of recalculating heights repeatedly, combining height computation with balance checking makes the solution both clean and efficient. Key Takeaways: -> Bottom-up recursion simplifies tree problems -> Early termination saves unnecessary computation -> Returning sentinel values (-1) is a powerful pattern -> One DFS can solve both height & balance checks Language: Java -> Runtime: 0 ms (Beats 100%) ⚡ -> Memory: 45.76 MB Staying consistent, one tree at a time. 🌳💻🔥 #LeetCode #Java #BinaryTree #Recursion #DFS #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 90 of #100DaysOfCode | LeetCode Daily Solved LeetCode Problem #401 – Binary Watch ⌚💻✅ A fun problem that blends bit manipulation with simple iteration. The idea is to count set bits for hours and minutes and generate all valid time combinations. Key Takeaways: -> Smart use of Integer.bitCount() for counting LEDs -> Separating hours (0–11) and minutes (0–59) cleanly -> Formatting time output correctly (leading zeros matter!) -> Brute force done right with clear constraints Language: Java -> Runtime: 3 ms (Beats 91.19%) -> Memory: 43.45 MB (Beats 94.31%) Consistency builds confidence. 90 days in — still pushing forward. 🔥💻 #LeetCode #Java #BitManipulation #BinaryWatch #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 38 of #100DaysOfLeetCode Today I solved "Container With Most Water" problem on LeetCode. 🔹 Difficulty: Medium 🔹 Concept Used: Two Pointer Technique 🔹 Language: Java 📌 Problem Summary: Given an array representing heights of vertical lines, the goal is to find two lines that together with the x-axis can contain the maximum amount of water. 💡 Approach: Instead of checking all possible pairs (O(n²)), I used the Two Pointer approach which reduces the time complexity to O(n). Steps: 1️⃣ Start with two pointers at the beginning and end of the array. 2️⃣ Calculate the area using the smaller height. 3️⃣ Move the pointer with the smaller height inward. 4️⃣ Track the maximum area during each step. 📊 Result: ✅ Runtime: 5 ms (Beats 81.86%) ✅ Memory: Beats 95.54% This problem was a great exercise to understand optimization using two pointers instead of brute force. Consistency is the key — moving forward one problem at a time! 💪 #LeetCode #100DaysOfCode #Java #DSA #CodingChallenge #ProblemSolving #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 88 of #100DaysOfCode | LeetCode Daily Solved LeetCode Problem #67 – Add Binary ➕💻✅ A clean fundamentals problem that reinforces how low-level operations really work under the hood. Simulating binary addition digit by digit with carry is simple, efficient, and elegant. Key Takeaways: -> Binary addition using carry logic -> Traversing strings from right to left -> Using StringBuilder for efficient string construction -> Handling edge cases when carry remains at the end Language: Java -> Runtime: 1 ms (Beats 99.65%) -> Memory: 43.90 MB Strong basics make complex problems easier. One day, one win. 🔥💻 #LeetCode #Java #Binary #Strings #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 6/100 – LeetCode Challenge 🚀 Problem: #189 Rotate Array Difficulty: Medium Language: Java Approach: Array Reversal Technique Time Complexity: O(n) Space Complexity: O(1) 🔍 Key Insight: Instead of shifting elements one by one, the array can be rotated efficiently using a three-step reversal strategy. Steps: 1️⃣ Reverse the entire array 2️⃣ Reverse the first k elements 3️⃣ Reverse the remaining elements This achieves the required rotation in-place with constant extra space. 🧠 Solution Brief: Calculated k % n to handle cases where k is greater than array length. Reversed the entire array first. Then reversed the first k elements and the remaining n-k elements. This sequence correctly rotates the array to the right. 📌 What I Learned: Understanding patterns like array reversal can simplify problems that initially seem complex. Optimizing from brute force shifting to an in-place O(n) solution improves efficiency. #LeetCode #Day6 #100DaysOfCode #Java #DSA #Arrays #RotateArray #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 46: Binary Addition from scratch! 🔢 Problem 67: Add Binary Java's BigInteger is a thing, but manual bit manipulation is just more satisfying. My approach: 1. Padded both strings to the same length using character arrays. 2. Simulated schoolbook addition from right to left. 3. Used % 2 for the result bit and / 2 for the carry. It’s a clean O(N) solution that avoids overflow and keeps the logic transparent. No shortcuts, just pure logic. 🚀 #LeetCode #Java #Binary #Algorithms #CodingChallenge #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 80 of #100DaysOfCode Solved LeetCode Problem #1653 – Minimum Deletions to Make String Balanced ✅ A clean greedy + DP-style problem that looks simple but really tests decision-making at each step. The trick is choosing whether to delete a character now or rely on previous counts to minimize total deletions. Key Takeaways: -> Greedy decisions can be optimized with running state -> Tracking counts (bCount) simplifies future choices -> Sometimes the best DP is just two variables -> Elegant logic beats complex data structures Language: Java -> Runtime: 19 ms (Beats 93.09%) ⚡ -> Memory: 47.80 MB Showing up daily, sharpening logic, and trusting the process. 💻🔥 #LeetCode #Java #Greedy #DynamicProgramming #Strings #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 44 - LeetCode Journey Solved LeetCode 917: Reverse Only Letters in Java ✅ A clean two-pointer problem that really tests your understanding of string manipulation. The goal was simple: reverse only the letters while keeping all non-letter characters in their original positions. Instead of creating extra data structures, I used two pointers from both ends. If a character is not a letter, we skip it. When both pointers land on letters, we swap them. This continues until the pointers meet. What I liked about this problem is how it teaches you to control movement smartly rather than brute forcing the solution. Key takeaways: • Two-pointer technique for efficient traversal • Handling edge cases (symbols, numbers) • Writing in-place logic without extra space • Clean and readable code ✅ All test cases passed ✅ 100% runtime performance Problems like this improve your thinking for real interview scenarios where optimization matters. #LeetCode #DSA #Java #Strings #TwoPointers #Algorithms #ProblemSolving #CodingJourney #InterviewPrep #Consistency
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development