🚀 Day 86 of #100DaysOfCode Solved LeetCode Problem #3714 – Longest Balanced Substring II ✅ This problem builds on Part I and demands a more optimized approach to track balance efficiently across the string. A great exercise in combining prefix-state tracking with hashing to avoid brute force. Key Takeaways: -> Using state compression to represent balance conditions -> Leveraging HashMap to store first occurrences for maximum length -> Thinking in terms of prefix differences rather than substrings -> Optimizing time complexity with smart observations Language: Java -> Runtime: 308 ms (Beats 77.17%) -> Memory: 156.78 MB Consistency compounds. One day, one problem. 💻🔥 #LeetCode #Java #DataStructures #Strings #HashMap #ProblemSolving #100DaysOfCode
LeetCode 3714: Longest Balanced Substring II in Java
More Relevant Posts
-
Day 10 – LeetCode question Solved LeetCode 560 – Subarray Sum Equals K (Medium) Approach: Prefix Sum + HashMap Maintained running cumulative sum Checked if (sum − k) existed in the map Used HashMap to store frequency of prefix sums Counted all valid subarrays efficiently Time Complexity: O(n) Space Complexity: O(n) Strengthened understanding of prefix sum patterns and hashmap-based optimizations for subarray problems. #LeetCode #Day10 #PrefixSum #HashMap #DSA #Java #ProblemSolving #Consistency #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 96 of #100DaysOfCode Solved LeetCode #1461 – Check If a String Contains All Binary Codes of Size K ✅ A solid mix of sliding window + bit manipulation, where efficiency really matters. Key Takeaways: -> Using rolling hash / bitmask to track binary substrings -> Avoiding substring overhead for better performance -> Understanding the limit: total required codes = 2^k -> Early pruning with length checks for optimization Language: Java -> Runtime: 6 ms (Beats 100%) ⚡ -> Memory: 47.73 MB Almost at the finish line — one binary string at a time 💻🔥 #LeetCode #Java #BitManipulation #SlidingWindow #Strings #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 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
-
-
🚀 Cracked LeetCode 189 – Rotate Array using an optimized in-place approach. Instead of brute force (O(n × k)), I implemented the reverse algorithm technique to achieve: ✅ Time Complexity: O(n) ✅ Space Complexity: O(1) ✅ 0 ms runtime (Beats 100%) Focused on improving optimization thinking and writing clean, efficient Java code. #LeetCode #Java #DataStructures #Algorithms #ProblemSolving #TechGrowth
To view or add a comment, sign in
-
-
🎯 Day 100 of #100DaysOfCode 🔥 What a way to wrap it up! Solved LeetCode #3666 – Minimum Operations to Equalize Binary String ✅ A problem that blends math, parity logic, and careful case analysis—not your usual binary flip question. Key takeaways: -> Count-based optimization over brute force -> Handling even/odd operation patterns smartly -> Early exits = cleaner & faster logic -> Thinking in terms of operations feasibility rather than simulation 🧠 Language: Java -> Runtime: 0 ms (Beats 83.87%) -> Memory: 47.90 MB 100 days. Countless problems. One habit built: consistency 💪 Onward to harder problems and deeper concepts 🚀 #LeetCode #Java #DSA #BinaryStrings #ProblemSolving #Consistency #100DaysChallenge
To view or add a comment, sign in
-
-
Day 12/100 – LeetCode Challenge Problem Solved: Permutations Today’s problem was about generating all possible permutations of a given array of distinct integers. This is a classic backtracking problem where the objective is to build permutations step by step while ensuring each element is used exactly once in every arrangement. I implemented a recursive solution supported by a boolean array to track which elements were already included in the current permutation. At every recursive call, I select an unused element, add it to the current list, mark it as used, and continue exploring deeper. Once a permutation reaches the required length, it is added to the result set. Then comes the most important part — backtracking. I remove the last element and reset its state so other combinations can be explored. Time Complexity: O(n × n!) Space Complexity: O(n) excluding the output list #100DaysOfLeetCode #Java #Backtracking #Recursion #Algorithms #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Strings look simple until edge cases show up 👀 Day 8 / #100DaysOfCode 🚀 Solved: Valid Palindrome (LeetCode 125) 🔹 Approach: Used the two-pointer technique starting from both ends. Ignored non-alphanumeric characters and compared characters after converting the string to lowercase. Time Complexity: O(n) Space Complexity: O(1) ✔ Practiced string traversal with pointers ✔ Handled real-world edge cases (spaces, symbols, cases) ✔ Avoided extra space by working in-place 💡 Takeaway: Clean pointer logic often beats preprocessing with extra data structures. Building strong fundamentals in Java, one problem at a time. #LearnInPublic #100DaysOfCode #DSA #Java #Strings #ProblemSolving #SoftwareEngineer #CodingJourney #Consistency
To view or add a comment, sign in
-
-
I revised LeetCode Problem #560 – Subarray Sum Equals K. I began with the brute force approach (O(N²)) to refresh my basic intuition and understand the problem flow clearly. Next, I transitioned to a more efficient and slightly tricky approach which was using a HashMap to store prefix sums. This optimization reduced the time complexity by leveraging cumulative sums and counting occurrences efficiently. Key takeaway: revisiting problems helps strengthen problem-solving patterns, especially around prefix sums and hash maps. Always learning, always improving. #LeetCode #DSA #CodingJourney #ProblemSolving #Java #SoftwareEngineering
To view or add a comment, sign in
-
Day 44: Avoiding the O(n²) Trap 🔍 Problem 3714: Longest Balanced Substring II Today’s goal: find the longest substring where all present characters appear equally. Since we only had 'a', 'b', and 'c' to deal with, I split the logic into three cases (1, 2, or 3 unique characters). Pro tip: I almost nuked my runtime by using map.clear() inside a loop. Since clear() iterates over the map to nullify entries, it’s O(n). Switching to new HashMap<>() kept the complexity at a clean O(1) reset and a total O(n) pass. Don't let built-in methods turn your linear solution into a nested nightmare. Complexity matters. 🧗♂️ #LeetCode #Java #CodingChallenge #ProblemSolving
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