🚀 Day 525 of #750DaysOfCode 🚀 💡 LeetCode 1980: Find Unique Binary String Today’s problem was an interesting one involving binary strings and a clever observation. We are given n unique binary strings of length n, and the task is to return any binary string of length n that does not exist in the given array. 🔎 Approach I Used I applied a concept similar to Diagonalization. Traverse the array from 0 → n-1 Look at the i-th character of the i-th string Flip it (0 → 1 or 1 → 0) Append the flipped character to build a new string This guarantees the newly created string differs from every string in the list at least at one position, ensuring it is unique and not present in the array. ⚡ Time Complexity: O(n) ⚡ Space Complexity: O(n) This approach works efficiently because the constraints are small and we only need to ensure one position difference with each string. Problems like this highlight how a simple observation can eliminate brute force completely. #leetcode #coding #programming #java #datastructures #algorithms #problemSolving #developer #codingchallenge #750DaysOfCode
LeetCode 1980: Unique Binary String Solution
More Relevant Posts
-
🚀 Day 535 of #750DaysOfCode 🚀 ✅ Solved: Count Submatrices with Top-Left Element and Sum ≤ k (LeetCode 3070) Today’s problem was a great example of using 2D Prefix Sum to optimize matrix queries. Instead of checking every possible submatrix, we can observe that the question only allows submatrices that include the top-left element (0,0). This means every valid submatrix is just a prefix rectangle, so we can compute the sum efficiently using prefix sums. 💡 Key Learning: Used 2D Prefix Sum technique Reduced brute force complexity to O(m × n) Learned how to handle matrix range sum problems efficiently 📌 Approach: Build prefix sum for each cell Check if sum from (0,0) to (i,j) ≤ k Count valid submatrices This problem improved my understanding of: ✔️ Prefix Sum ✔️ Matrix DP patterns ✔️ Optimization from brute force to efficient solution Consistency continues 🔥 On to Day 536 tomorrow. #leetcode #java #datastructures #algorithms #codingchallenge #prefixsum #matrix #programming #softwareengineering #750daysofcode
To view or add a comment, sign in
-
-
🚀 Day 23/60 — LeetCode Discipline Problem Solved: Remove Duplicates from Sorted Array (Revision) Difficulty: Easy Today’s practice focused on revisiting a classic array problem that leverages the two-pointer technique. Since the array is already sorted, duplicates naturally appear next to each other. The idea is to maintain one pointer for the position of the last unique element and another pointer to traverse the array, updating the array in-place whenever a new unique value appears. Problems like this beautifully demonstrate how understanding the structure of the data can simplify the solution significantly. 💡 Focus Areas: • Strengthened two-pointer array technique • Practiced in-place array modification • Reinforced understanding of sorted array properties • Improved clean and efficient iteration logic • Focused on writing simple and readable code ⚡ Performance Highlight: Achieved ~79% runtime efficiency on submission. Consistent practice with classic problems continues to refine core algorithmic patterns and strengthen problem-solving discipline. #LeetCode #60DaysOfCode #100DaysOfCode #DSA #TwoPointers #Arrays #Algorithms #DataStructures #ProblemSolving #CodingJourney #SoftwareEngineering #Programming #Developers #TechCareers #Java
To view or add a comment, sign in
-
-
🚀 Day 24/60 — LeetCode Discipline Problem Solved: Symmetric Tree (Revision) Difficulty: Easy Today’s practice focused on revisiting a classic binary tree problem — checking whether a tree is symmetric around its center. The key idea is to treat the left and right subtrees as mirror images and recursively compare their corresponding nodes. By verifying both structure and node values simultaneously, the algorithm determines whether the tree maintains perfect symmetry. Problems like this highlight how recursion naturally fits tree-based structures and helps simplify complex comparisons. 💡 Focus Areas: • Strengthened recursive tree traversal • Practiced mirror comparison of subtrees • Improved understanding of binary tree symmetry • Reinforced recursive problem-solving patterns • Focused on writing clean and structured logic ⚡ Performance Highlight: Achieved 0 ms runtime (100% performance) on submission. Consistent practice across arrays, strings, stacks, bit manipulation, and now tree structures continues to deepen my overall algorithmic intuition. #LeetCode #60DaysOfCode #100DaysOfCode #DSA #BinaryTree #Recursion #Algorithms #DataStructures #ProblemSolving #CodingJourney #SoftwareEngineering #Programming #Developers #TechCareers #Java
To view or add a comment, sign in
-
-
🚀 Day 42 of My LeetCode Journey Today’s problem: Regular Expression Matching This wasn’t just another coding problem — it forced me to think in terms of state transitions and decision trees, not brute force. 🔍 Key Learning: - Pure recursion is not enough → leads to exponential time - Introduced Dynamic Programming (Top-Down with Memoization) - Learned how to break the problem into: - Matching current characters - Handling "*" (zero or more occurrences) 🧠 Core Insight: Instead of trying all possibilities blindly, cache results of subproblems → avoids recomputation. ⚡ Result: - Runtime: 1 ms (Beats 99.99%) - Efficient DP solution with optimal pruning 💡 Takeaway: Hard problems aren’t about syntax — they’re about modeling the problem correctly. #Day42 #LeetCode #DataStructures #DynamicProgramming #Java #CodingJourney
To view or add a comment, sign in
-
-
Day 38 of 100 Days of LeetCode Challenge Today’s problem: Sum of All Odd Length Subarrays My approach: The goal of this problem is to find the sum of all subarrays whose length is odd. Instead of generating every subarray explicitly, I focused on understanding how many times each element contributes to an odd length subarray. For every element at index i, I first calculate how many total subarrays include that element. This can be found using the formula (i + 1) * (n - i), where n is the length of the array. This represents the number of ways we can choose the start and end positions so that the element at index i is included. Out of these total subarrays, only half of them will have odd length. So we calculate the number of odd subarrays using (total + 1) / 2. Then the contribution of the element to the final sum is its value multiplied by the number of odd subarrays it appears in. By repeating this for every element and adding all contributions together, we get the final answer efficiently in linear time. Consistency is not about doing something big once. It is about doing small things every single day until they become powerful results. #100DaysOfLeetCode #LeetCode #DataStructures #Algorithms #ProblemSolving #CodingJourney #Consistency #DailyCoding #Java
To view or add a comment, sign in
-
-
Today I finally understood the logic behind the Longest Substring Without Repeating Characters problem from LeetCode — and honestly, the journey of understanding it was more valuable than just getting the answer. At first, the idea of Sliding Window felt confusing. I couldn’t visualize how the substring keeps changing and how the algorithm still finds the correct result. So instead of jumping straight to the code, I broke it down step by step like a beginner: Example string: pwwkew I started tracking a window of characters: [p] [p,w] duplicate w → remove from front [w] [w,k] [w,k,e] duplicate w → remove until duplicate gone [k,e,w] The key insight that finally clicked for me: The window keeps changing, but a separate variable keeps track of the best result. currentLength = end - start + 1 maxLength = Math.max(maxLength, currentLength) So even though the window moves, the algorithm never loses the best answer it has seen so far. This problem helped me understand two important concepts: • Sliding Window technique • Maintaining a running best value (maxLength) Sometimes the real learning happens when you slow down and understand the logic instead of just memorizing the solution. Still learning, still exploring. 🚀 #DSA #Java #ProblemSolving #CodingJourney #SlidingWindow
To view or add a comment, sign in
-
Day 38 of My DSA Journey Today I solved LeetCode 152 – Maximum Product Subarray on LeetCode. 📌 Problem Given an integer array nums, find the contiguous subarray that has the largest product, and return that product. Example: Input: [2,3,-2,4] Output: 6 → subarray [2,3] 🧠 Approach – Dynamic Programming (Tracking Max & Min) This problem is tricky because of negative numbers. Key Idea: • At each index, we maintain: maxProduct → maximum product ending at current index minProduct → minimum product ending at current index 👉 Why min? Because a negative number can turn a small (negative) product into a large positive one. Steps I followed: • Initialize maxProduct, minProduct, and ans with the first element • Traverse the array from left to right • If the current number is negative → swap max and min • Update: maxProduct = max(current, current × maxProduct) minProduct = min(current, current × minProduct) • Update the final answer using maxProduct ⏱ Time Complexity: O(n) — Single pass through the array 📦 Space Complexity: O(1) — No extra space used 💡 Key Learnings ✔ Handling negative numbers in product problems ✔ Using dynamic programming with state tracking ✔ Understanding why tracking both max & min is important This is one of those problems that looks simple but tests deep understanding of edge cases 🚀 Consistency continues — leveling up every day 💪 #100DaysOfCode #DSA #DynamicProgramming #Arrays #LeetCode #Java #ProblemSolving #CodingJourney #DeveloperJourney #Programming #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 49 of #100DaysOfCode ✅ Solved: Find the Difference 🔍 What I did: Used a clever XOR bit manipulation technique to identify the extra character between two strings efficiently. 💡 Key Learning: XOR cancels out identical characters Helps find unique elements in linear time Clean and optimal approach without extra space ⚡ Time Complexity: O(n) 📦 Space Complexity: O(1) 🎯 Takeaway: Sometimes the best solutions are not obvious — learning small tricks like XOR can make a big difference in problem solving. #Java #LeetCode #ProblemSolving #CodingJourney #100DaysChallenge #DataStructures #Algorithms
To view or add a comment, sign in
-
-
Day 70 - LeetCode Journey Solved LeetCode 88: Merge Sorted Array (Easy) today — a classic problem that focuses on array manipulation and the two-pointer technique. The challenge is to merge two sorted arrays into one sorted array without using extra space, by modifying nums1 in-place. 💡 Core Idea: Instead of merging from the beginning, we start from the end of the arrays. Why? Because nums1 already has extra space at the end to accommodate elements from nums2. We use three pointers: • i → last valid element in nums1 • j → last element in nums2 • k → last position of merged array At each step, we place the larger element at position k, ensuring the array remains sorted. ⚡ Key Learning Points: • Using the two-pointer technique from the end • Performing in-place array merging • Maintaining O(m + n) time complexity • Avoiding unnecessary extra space This problem is a great reminder that sometimes changing the direction of traversal makes the solution much simpler. ✅ Better understanding of array manipulation ✅ Stronger grasp of two-pointer techniques ✅ Improved problem-solving efficiency Small problems like this build strong fundamentals for bigger challenges 🚀 #LeetCode #DSA #Java #TwoPointers #Arrays #Algorithms #ProblemSolving #CodingJourney #Consistency #100DaysOfCode #InterviewPreparation #DeveloperGrowth #KeepCoding
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 𝟲𝟵/𝟭𝟬𝟬 — 𝗥𝗲𝗺𝗼𝘃𝗲 𝗞 𝗗𝗶𝗴𝗶𝘁𝘀 Day 69. One day from 70. This problem broke my brain. Then it clicked. 𝗧𝗼𝗱𝗮𝘆'𝘀 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: ✅ #𝟰𝟬𝟮: Remove K Digits (Medium) 𝗧𝗵𝗲 𝗣𝗿𝗼𝗯𝗹𝗲𝗺: Given a number as a string and k, remove k digits to make the smallest possible number. Example: "1432219", k=3 → "1219" Which 3 digits do you remove? And in what order? 𝗧𝗵𝗲 𝗜𝗻𝘀𝗶𝗴𝗵𝘁: Greedy + Monotonic Stack. Remove a digit if the next digit is smaller. Keep the stack increasing. This builds the smallest number left-to-right. Example: "1432219" See '4' then '3'? Remove '4' See '3' then '2'? Remove '3' See '2' then '2'? Keep both Result: "12219" → remove trailing '9' → "1219" 𝗠𝘆 𝗦𝗼𝗹𝘂𝘁𝗶𝗼𝗻: StringBuilder as stack. For each digit: While stack top > current digit AND k > 0: pop and decrement k Append current digit After loop, remove remaining k digits from the end. Strip leading zeros. Time: O(n), Space: O(n) 𝗪𝗵𝘆 𝗜𝘁 𝗠𝗮𝘁𝘁𝗲𝗿𝘀: This combines greedy thinking with monotonic stack. Two patterns, one solution. Understanding when to be greedy and when to use a stack—that's the skill. 𝗖𝗼𝗱𝗲: https://lnkd.in/gv36YUfj 𝗗𝗮𝘆 𝟲𝟵/𝟭𝟬𝟬 ✅ 𝟲𝟵 𝗱𝗼𝘄𝗻. 𝟯𝟭 𝘁𝗼 𝗴𝗼. 𝗧𝗼𝗺𝗼𝗿𝗿𝗼𝘄 = 𝟳𝟬. #100DaysOfCode #LeetCode #MonotonicStack #GreedyAlgorithm #Algorithms #CodingInterview #Programming #Java #MediumLevel #PatternCombination #Day70Tomorrow
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