🚀 Day 7️⃣7️⃣ of #100DaysOfCode Solved LeetCode Problem #1437 — Check If All 1’s Are at Least K Places Away 🔍✨ 🔧 Concept: Given a binary array, ensure that every 1 is separated by at least K zeros. The solution simply tracks the previous index of 1 and checks the distance. 🧠 Key Idea: Scan the array once When a 1 is found, verify: 👉 currentIndex - previousIndex > k If any pair violates this, return false ⚡ Efficient: Time Complexity: O(n) Space Complexity: O(1) Another clean and efficient logical problem solved. #LeetCode #Java #Arrays #ProblemSolving #DSA #CodingJourney #100DaysOfCode #DeveloperLife #Motivation
Solved LeetCode Problem #1437: Check 1's Separation in Binary Array
More Relevant Posts
-
Day 32 of #100DaysOfCode 🚀 Combination Sum III (Leetcode) Approach (Backtracking): This problem is about choosing k numbers (1–9) that add up to a given sum n. -> used backtracking to explore combinations step-by-step: *Start from a number 1 to 9 *Pick a number if it doesn’t exceed the remaining target *Move to the next number (i+1) to maintain uniqueness *If we have picked k numbers and the target becomes 0, store the combination. *Backtrack and try other possibilities *It’s a clean recursive pattern: pick → explore → unpick → continue. #100DaysOfCode #LeetCode #Java #DSA #CodingJourney #Backtracking #ProblemSolving #LearningEveryda
To view or add a comment, sign in
-
-
Day 45/100 – #100DaysOfCode 🚀 Solved Remove All Adjacent Duplicates in String (LeetCode) using a Stack. Approach : -> Traverse the string character by character. -> If the stack is not empty and the top character is the same as the current one → pop it (remove the duplicate). -> Otherwise, push the current character onto the stack. -> After processing the full string, the stack contains the final characters (in reverse order). -> Build the result by popping from the stack and reversing it. This approach works in O(n) time and avoids unnecessary comparisons. #DSA #Stacks #LeetCode #ProblemSolving #Java #LearningEveryday #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 13 of #100DaysOfCode – Binary Search in Action-Today I solved LeetCode 1283: Find the Smallest Divisor Given a Threshold and it was a great example of how Binary Search can be applied beyond sorted arrays. 👉 This monotonic behavior makes the problem perfect for Binary Search. ⏱️ Complexity Time: O(n log max(nums)) Space: O(1) 📌 Key Takeaway Binary Search isn’t just for sorted arrays — 👉 If the answer space is monotonic, Binary Search can optimize it efficiently. #100DaysOfCode #Day12 #BinarySearch #LeetCode #Java #DSA #ProblemSolving #CodingJourney 💻✨
To view or add a comment, sign in
-
-
Day 18 of my LeetCode Journey: Problem: Search in a 2D Matrix Approach: Started from the top-right corner of the matrix. At each step: If the value is greater than target → move left If smaller → move down If equal → found the target This works because rows and columns are both sorted, allowing us to eliminate one row or column at every step. Time Complexity: O(m + n) Space Complexity: O(1) Key insight: Using matrix properties smartly can avoid unnecessary binary searches. Using matrix properties smartly can avoid unnecessary binary searches. On to Day 19 💪 #LeetCode #DSA #Java #ProblemSolving #CodingJourney #Consistency #1001DaysOfCode
To view or add a comment, sign in
-
-
🔹 Day 91 – LeetCode Practice 📌 Problem: Three Consecutive Odds (LeetCode #1550) 📊 Difficulty: Easy 🧠 Problem Overview: Given an integer array, determine whether there are three consecutive odd numbers appearing next to each other. Return true if such a sequence exists; otherwise, return false. ✅ My Approach: Traversed the array while keeping track of consecutive odd numbers. Increased a counter whenever an odd number appeared and reset it when an even number was found. As soon as the counter reached three, the condition was satisfied. 📈 Complexity Analysis: Time Complexity: O(n) Space Complexity: O(1) 🚀 Submission Results: Status: Accepted ✅ Runtime: 0 ms (Beats 100%) 🚀 Memory: 44.18 MB (Beats 38.42%) 💡 Reflection: This problem highlights how a simple counter-based logic can efficiently solve pattern-detection tasks. Clean logic and early exits make solutions both fast and readable. #LeetCode #DSA #Java #ProblemSolving #CodingPractice #LearningJourney
To view or add a comment, sign in
-
-
#200DaysOfCode – Day 106 Backtracking & Recursion | Combination Sum II Problem: Combination Sum II Task: Given an array of candidate numbers and a target, find all unique combinations where the numbers sum up to the target. Each number can be used only once, and duplicate combinations are not allowed. Example: Input: candidates = [10,1,2,7,6,1,5], target = 8 Output: [1,1,6], [1,2,5], [1,7], [2,6] My Approach: Sorted the array to handle duplicates efficiently. Used backtracking to explore all valid combinations. Skipped duplicate elements to avoid repeated combinations. Pruned recursion when the current value exceeded the target. Time Complexity: Exponential (Backtracking) Space Complexity: O(N) due to recursion stack Backtracking becomes much cleaner and more efficient when combined with sorting and smart pruning. Understanding when to skip elements is just as important as choosing them. #takeUforward #100DaysOfCode #Java #ProblemSolving #LeetCode #Backtracking #Recursion #DSA #CodingJourney #CodeNewbie #Consistency
To view or add a comment, sign in
-
-
🚀 21 Days of Code — Day 1/21 Restarting my 21 Days of Code journey with a problem that helped me revisit binary representation and bit manipulation fundamentals. ⸻ 🧩 Problem Statement A positive integer N is given. Steps to solve: 1. Convert the decimal number to its binary representation 2. Toggle all bits starting from the most significant bit (including MSB) 3. Convert the toggled binary back to decimal and print the result 📌 Example: Input: 8 Binary: 1000 After toggling: 0111 Output: 7 ⸻ 💡 Approach I Used • Converted the decimal number to binary using bitwise AND (&) and right shift (>>) • Stored the binary representation manually • Toggled each bit by checking '0' and '1' • Recalculated the decimal value of the toggled binary 🔍 Key Takeaway Working at the bit level strengthens logical thinking and makes complex-looking problems much easier to break down. 📌 Day 1/21 complete Consistency over perfection — showing up every day 💪 #21DaysOfCode #Java #BitManipulation #DigitalLogic #DSA #LearningInPublic #ProblemSolving #DrGVishwanathanChallenge
To view or add a comment, sign in
-
-
LeetCode Practice - 747. Largest Number At Least Twice of Others ✅ Approach (Simple Logic) 1. Read the size of the array. 2. Read array elements dynamically. 3. Find: 📌the largest number 📌its index 4. Check whether the largest number is at least twice every other number. 5. If yes → return its index Else → return -1 #LeetCode #Java #CodingPractice #ProblemSolving #DSA #Array #DeveloperJourney #TechLearning
To view or add a comment, sign in
-
-
Day 37/100 – #100DaysOfCode 🚀 Number of Subarrays of Size K with Average ≥ Threshold” (LeetCode). Approach: --> Used the sliding window technique since the subarray size is fixed. *First, calculate the sum of the first window of size k. *Check if its average (sum / k) meets the threshold. *Then slide the window one step at a time by removing the left element and adding the new right element. *Each slide updates the sum in constant time and avoids recalculating from scratch. *This way, the problem is solved in O(n) time instead of using nested loops. Key Takeaway: #DSA #SlidingWindow #ProblemSolving #LeetCode #Java #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