🚀 Day 146 / 180 of #180DaysOfCode ✅ Today’s Highlight: Revisited LeetCode 3234 — “Count the Number of Substrings With Dominant Ones.” 🧩 Problem Summary: Given a binary string s, the task is to count how many of its substrings have dominant ones. A substring is considered dominant if: number of 1s ≥ (number of 0s)² This creates an interesting balance check between zeros and ones, pushing you to think about substring ranges, prefix behavior, and efficient counting techniques. 💡 Core Takeaways: Great exercise in string analysis and prefix-based reasoning Highlights how mathematical conditions influence algorithm design Reinforces handling frequency relationships inside a sliding or expanding window Efficient counting becomes essential due to potential O(n²) substrings 💻 Tech Stack: Java ⏱ Runtime: 115 ms (Beats 84.11%) 💾 Memory: 47 MB 🧠 Learnings: Strengthened understanding of substring behavior under unique constraints Refined thinking around optimizing brute-force patterns A good reminder of how theoretical conditions (like squaring zeros) change practical implementation choices 📈 Progress: Today’s problem significantly improved my intuition around constraint-based substring evaluation—valuable for more advanced algorithmic challenges ahead. #LeetCode #Java #Algorithms #SubstringProblems #DSA #ProblemSolving #CodingJourney #SoftwareEngineering #180DaysOfCode #LogicBuilding #LearningEveryday
Revisiting LeetCode 3234: Counting Dominant Substrings in Java
More Relevant Posts
-
Problem 27 : LeetCode 🎯 LeetCode Problem #645 Solved — Set Mismatch (Cyclic Sort Approach) 🧩 Today, I solved another interesting LeetCode Easy problem — “Set Mismatch”, which deepened my understanding of in-place sorting and index mapping using the Cyclic Sort technique. 🔍 Problem Overview Given an integer array nums where numbers are supposed to be from 1 to n, one number is duplicated, and one number is missing. The task: Find both numbers using O(n) time and O(1) space. 💡 My Approach — Cyclic Sort Technique I treated the array like a self-mapping structure where each number x should ideally be placed at index x - 1. If the current element isn’t in its correct place and its target isn’t already filled, I swap it. After the array is sorted in place, any index i where arr[i] != i + 1 indicates: arr[i] → the duplicate number i + 1 → the missing number ⚙️ Results ✅ Runtime: 3 ms — Beats 79.76% of Java submissions ✅ Memory: 47.45 MB — Beats 6.28% of submissions ✅ Complexity: O(n) time | O(1) space ✅ Status: Accepted ✅ (All 49 test cases passed) 🧩 Tech Stack Java | Cyclic Sort | Array Manipulation | In-Place Algorithm | DSA Another problem that reinforces my confidence in index-based logic and memory-efficient coding patterns — vital skills for backend and system optimization. #LeetCode #Java #ProblemSolving #CyclicSort #DataStructures #Algorithms #InPlaceAlgorithm #BackendDevelopment #SpringBoot #DSA #LearningInPublic #CodingJourney Question Url : https://lnkd.in/dixwjFE3
To view or add a comment, sign in
-
-
💡 LeetCode 3370 – Smallest Number With All Set Bits Greater Than or Equal to n 💡 Today, I solved LeetCode Problem #3370, a concise yet insightful bit manipulation problem that sharpened my understanding of binary operations and number construction using bitwise logic in Java. ⚙️💻 🧩 Problem Overview: Given an integer n, the task is to find the smallest number that is greater than or equal to n and has all bits set to 1 in its binary form. 👉 Examples: Input → n = 5 (binary 101) → Output → 7 (binary 111) Input → n = 10 (binary 1010) → Output → 15 (binary 1111) 💡 Approach: 1️⃣ Initialize x = 1 (binary 1). 2️⃣ Continuously left-shift and OR with 1 → x = (x << 1) | 1, until x becomes ≥ n. 3️⃣ Return x as the final result — a number with all bits set to 1 that satisfies the condition. ⚙️ Complexity Analysis: ✅ Time Complexity: O(log n) — Each iteration handles one bit of n. ✅ Space Complexity: O(1) — Uses only constant extra space. ✨ Key Takeaways: Reinforced understanding of bitwise shift (<<) and bitwise OR (|) operators. Demonstrated how to efficiently generate numbers following binary patterns. Proved that elegant logic often lies in simplicity — especially in bit manipulation problems. 🌱 Reflection: This problem showcases how bit-level operations can simplify what might seem like mathematical complexity. Mastering these techniques is essential for building deeper intuition in algorithms and optimization. 🚀 #LeetCode #3370 #Java #BitManipulation #BinaryLogic #DSA #ProblemSolving #AlgorithmicThinking #CodingJourney #CleanCode #ConsistencyIsKey
To view or add a comment, sign in
-
-
🚀 Day-75 of #100DaysCodeOfChallenge 💡 LeetCode Problem: 1526. Minimum Number of Increments on Subarrays to Form a Target Array (Hard) 🧠 Concepts Practiced: Greedy Algorithms | Array Manipulation | Difference Computation Today’s challenge was a Hard-level problem, focusing on finding the minimum number of operations required to transform an initial array of zeros into a given target array — using only subarray increments. The key insight here was realizing that each increase in value from one element to the next represents a required new operation on LeetCode. Instead of simulating every subarray operation, we can simply sum up the positive differences between consecutive elements — a great example of mathematical optimization through observation 💭 🔹 Intuition: Only when a number increases compared to the previous one, a new increment operation is needed. ⚙️ Language: Java ⚡ Runtime: 3 ms (Beats 100%) 💾 Memory: 56.82 MB (Beats 61.41%) ✅ Result: 129 / 129 test cases passed — Accepted! 🎯 Each “hard” problem solved adds one more layer of confidence — and reminds me that persistence pays off 💪 #100DaysOfCode #LeetCode #Java #ProblemSolving #Algorithms #CodingChallenge #GreedyAlgorithm #LearningJourney #TechMindset #KeepCoding #SoftwareEngineering #DeveloperLife #LogicBuilding
To view or add a comment, sign in
-
-
🚀 Day 60 of #100DaysOfCode 🚀 Today, I solved LeetCode Problem #137 – Single Number II 🧩 📘 Problem Statement: Given an integer array where every element appears three times except for one that appears exactly once, find that single element and return it. The challenge: solve it with O(n) time and O(1) space complexity. 💻 Language: Java ⚡ Runtime: 0 ms — Beats 100.00% 📉 Memory: 45.54 MB — Beats 56.30% 🧠 Concept Used: 🔹 Bit Manipulation — A powerful yet tricky technique that leverages binary operations to track occurrences of bits efficiently. 🔹 Instead of using extra space or hash maps, we track bits that appear once and twice using two integer variables: ✅ once → bits that appeared once ✅ twice → bits that appeared twice The trick lies in updating them using XOR (^) and NOT (~) to "cancel out" bits appearing three times. 🧩 Approach Summary: 1️⃣ Initialize two variables once = 0 and twice = 0. 2️⃣ For every number in the array: - Update once and twice based on how many times a bit has appeared. 3️⃣ After processing all numbers, once holds the value of the single element. ✅ Complexity: Time: O(n) Space: O(1) ✨ Takeaway: This problem teaches how bitwise logic can replace traditional data structures, achieving the same result with constant space — a crucial optimization in system-level programming and interviews. #100DaysOfCode #LeetCode #Java #BitManipulation #ProblemSolving #CleanCode #DataStructures #Algorithms #TechLearning #CodingChallenge #SoftwareEngineering #InterviewPreparation
To view or add a comment, sign in
-
-
🔥 Day 28 | LeetCode Challenge – Insert Interval (Problem #57) Today's challenge involved inserting a new interval into a list of non-overlapping, sorted intervals, while ensuring the resulting list remains sorted and still contains no overlapping intervals. 💡 Concept Overview: Each interval is defined by a start and end boundary. When inserting a new interval, we must consider whether it: Appears entirely before existing intervals, Appears entirely after existing intervals, or Overlaps with one or more intervals and therefore requires merging. 🧭 Approach Implemented: Iterated through the list of intervals and categorized them based on their relation to the new interval: No overlap (before): Current interval ends before new interval starts → add it directly. No overlap (after): Current interval starts after new interval ends → add the current new interval to result and shift new interval forward. Overlapping: Merge the intervals by updating the new interval's start and end boundaries. After all intervals were processed, appended the final version of the new interval. This ensures a single pass solution with efficient merging logic. ⚙️ Technical Summary: Algorithm: Interval Merging with Linear Scan Language: Java Runtime: 1 ms (Beats 98.92%) Memory: 47.12 MB 🧠 Key Insight: The problem highlights how sorted input allows for linear-time merging, avoiding unnecessary scanning or reprocessing. The structure of the input itself provides efficiency. #Day28 #LeetCode #InsertInterval #Intervals #MergingIntervals #AlgorithmEfficiency #JavaDeveloper #100DaysOfCode #ProblemSolving #DataStructuresAndAlgorithms #CodingChallenge #ContinuousLearning #TechProgress
To view or add a comment, sign in
-
-
🚀 Day 52 of #100DaysOfCode 🚀 Today I solved LeetCode Problem #389 – Find the Difference 🧩 This problem is a great example of using ASCII value manipulation to solve what seems like a string comparison challenge. 💡 Key Learnings: Strengthened understanding of character encoding (ASCII values) and how they can simplify logic. Learned how summing character values can help detect differences efficiently without extra data structures. Reinforced the value of O(n) solutions for string-based problems. 💻 Language: Java ⚡ Runtime: 1 ms — Beats 99.32% 🚀 📉 Memory: 41.9 MB — Beats 65.84% 🧠 Approach: 1️⃣ Convert both strings to character arrays. 2️⃣ Compute the sum of ASCII values of both. 3️⃣ The difference between sums gives the ASCII value of the extra character in t. Simple, elegant, and efficient! ⚙️ Sometimes, a clever use of ASCII arithmetic can replace complex logic — efficiency lies in simplicity. #100DaysOfCode #LeetCode #Java #ProblemSolving #CodingChallenge #Algorithms #DataStructures #SoftwareDevelopment #LearningEveryday #CleanCode
To view or add a comment, sign in
-
-
🔥 Day 29 | LeetCode Challenge – Merge Intervals (Problem #56) Today’s challenge involved consolidating overlapping intervals from a given list. Each interval represents a continuous segment, and the objective is to merge all intervals that overlap to produce a simplified, non-overlapping set that covers the same ranges. 💡 Concept Overview: Merging intervals efficiently requires sorting the input by start times. Once sorted, intervals can be processed in a single pass to determine if consecutive intervals overlap, and if so, they are merged by extending the boundary of the previous interval. 🧭 Approach Implemented: Sorted all intervals by their starting value. Iterated through the intervals: If the result list is empty or the current interval does not overlap the last interval in result → add it directly. Otherwise, update the end boundary of the last interval in result to: max(current_end, last_intervals_end) ensuring merged coverage. Returned the merged list of intervals. This approach ensures a clean O(n log n) time complexity due to sorting, followed by an O(n) merge sweep. ⚙️ Technical Summary: Algorithm: Sorting + Linear Merge Language: Java Runtime: 8 ms (Beats 85.85%) Memory: 49.14 MB 🧠 Key Insight: Sorting provides structure. Once intervals are ordered, overlapping detection and merging become straightforward. The task exemplifies how pre-processing (sorting) can simplify downstream logic dramatically. #Day29 #LeetCode #MergeIntervals #SortingAndMerging #AlgorithmDesign #JavaDeveloper #ProblemSolving #100DaysOfCode #DataStructuresAndAlgorithms #CodingChallenge #TechLearning #ContinuousImprovement
To view or add a comment, sign in
-
-
🚩 Problem: 78. Subsets 🔥 Day 56 of #100DaysOfLeetCode 🔍 Problem Summary: Given an integer array nums, return all possible subsets (the power set). The solution set must not contain duplicates, and the order does not matter. 🧠 Intuition: This is one of the simplest and cleanest backtracking problems. At each index, you have only two choices: Include the current element Exclude the current element This naturally builds the entire power set. Alternatively, you can also build subsets by expanding a list from left to right. ✅ Backtracking Approach: Start with an empty subset Recursively explore adding each number After each choice, backtrack and remove it Add all generated combinations into the result Super clean and beginner-friendly. ⚙️ Performance: ⏱️ Runtime: 1 ms 🚀 💪 Beats: 97% of Java solutions 💾 Memory: 43 MB ⚡ (Beats ~90% of users) 📊 Complexity: Time Complexity: O(n × 2ᶰ) Space Complexity: O(n) (recursion + temp list) ✨ Key Takeaway: This problem teaches the classic recursive structure used for: Subsets Combinations Nested choices Decision-tree exploration It's the perfect stepping stone to more advanced backtracking problems. Link:[https://lnkd.in/gfQV_8w4] #100DaysOfLeetCode #Day56 #Problem78 #Subsets #Backtracking #Recursion #Algorithms #DSA #Java #ProblemSolving #LeetCode #CodingChallenge #CodingCommunity #InterviewPreparation #CrackingTheCodingInterview #SoftwareEngineering #DataStructures #ArjunInfoSolution #DeveloperJourney #LearnToCode #TechCareers #CareerGrowth #CodeNewbie #ZeroToHero #CodingIsFun #JavaDeveloper #GameDeveloper #Unity #AI #MachineLearning
To view or add a comment, sign in
-
-
🚀 Problem 2: Reverse Integer 💡 Leetcode Problem No: 7 Today, I solved an interesting Leetcode-style problem that involves reversing an integer — while handling tricky cases like integer overflow 🔄 ✨ Challenge: Given an integer x, reverse its digits and return the reversed number. If reversing x causes the value to go outside the signed 32-bit integer range, return 0. 💻 Key Learnings: 🔹 Used Math.abs(x) to handle negatives elegantly 🔹 Applied overflow check using: if (rev > (Integer.MAX_VALUE - d) / 10) 🔹 Mastered modulus (%) and division (/) logic for digit extraction 🔹 Ensured both positive and negative numbers are correctly reversed 💙 Tip: Always consider edge cases and overflow conditions when working with integer manipulation problems. #Java #Coding #LeetCode #ProblemSolving #JavaDeveloper #ProgrammingChallenge #LeetcodeCoding
To view or add a comment, sign in
-
Explore related topics
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