Day 10/100 – DSA Challenge Today’s problem: Move Zeroes (LeetCode 283) What I Learned: The goal was to move all zeroes to the end of an array while maintaining the relative order of non-zero elements — and importantly, doing it in-place. Key Idea: Two-Pointer Technique I used a two-pointer approach: One pointer (fast) iterates through the array Another pointer (slow) tracks where the next non-zero element should go Whenever a non-zero element is found, it is swapped with the element at the slow pointer, ensuring all non-zero elements are shifted forward while zeroes naturally move to the end. Why this approach? Maintains order of elements Works in O(n) time complexity Uses O(1) extra space (in-place) Takeaway: This problem reinforced how powerful the two-pointer technique is for array manipulation problems, especially when constraints require in-place operations. Looking forward to tackling more problems and improving consistency! #Day10 #100DaysOfCode #DSA #Python #CodingJourney #LeetCode #ProblemSolving
Move Zeroes in Array with Two-Pointer Technique
More Relevant Posts
-
🚀 Day 83 of #100DaysOfCode 📌 Problem Solved: Letter Combinations of a Phone Number (LeetCode 17) Today’s challenge was all about exploring backtracking and how recursive decision-making builds combinations efficiently. 🔍 Given a string of digits (2–9), the goal is to generate all possible letter combinations based on the classic phone keypad mapping. 💡 Key Learning: Instead of trying every possible string blindly, backtracking helps us build combinations step-by-step and explore only valid paths — making the solution clean and efficient. ⚡ Highlights: ✔️ Used recursion to explore all possibilities ✔️ Implemented a digit-to-letter mapping ✔️ Built combinations incrementally ✔️ Achieved optimal runtime performance 📈 Result: ✅ All test cases passed ⚡ 0 ms runtime (Beats 100%) Consistency is starting to compound — one problem at a time. 💪 #LeetCode #DSA #Python #CodingJourney #Backtracking #100DaysOfCode
To view or add a comment, sign in
-
-
🚀Day-7 LeetCode Problem Solved – #3 Longest Substring Without Repeating Characters Today I solved one of the most popular Sliding Window problems on LeetCode: Longest Substring Without Repeating Characters 💡 Problem Summary: Given a string, find the length of the longest substring without any repeating characters. 🔍 Approach Used: I solved this using the Sliding Window + HashSet technique. The idea is to maintain a window of unique characters using two pointers: - left → start of the window - right → end of the window - set → stores current unique characters Whenever a duplicate character appears, I move the left pointer until the duplicate is removed, while continuously tracking the maximum length. ✨ Key Learning: This problem helped me strengthen my understanding of: - Sliding Window - Two Pointers - HashSet / Set operations - Time complexity optimization ⚡ Complexity: Time: O(n) Space: O(n) Every problem solved is one step closer to mastering DSA and problem-solving skills 💻 #LeetCode #DSA #Python #ProblemSolving #CodingJourney #SoftwareDeveloper #SlidingWindow #100DaysOfCode #InterviewPreparation
To view or add a comment, sign in
-
-
🚀 Day 96 of #LeetCode Journey 📌 Problem: Count and Say (Medium) Today’s problem looked simple at first glance—but it quickly tested my ability to observe patterns and think recursively. 🔍 Key Idea: The sequence builds itself by describing the previous term: - Start with "1" - Then keep "reading" the digits of the last result Example progression: 1 → "1" 2 → "11" (one 1) 3 → "21" (two 1s) 4 → "1211" (one 2, one 1) 💡 What I learned: - This problem is all about pattern recognition + string manipulation - It’s essentially run-length encoding (RLE) - Breaking the problem into a helper logic made it much cleaner ⚡ Challenges faced: - Handling consecutive characters correctly - Avoiding off-by-one mistakes while traversing - Keeping the logic readable instead of overcomplicating 📈 Outcome: ✅ Accepted ⚡ Runtime: 7 ms Consistency > Motivation. Showing up every day. #Day96 #LeetCode #DSA #ProblemSolving #CodingJourney #Python #Consistency
To view or add a comment, sign in
-
-
🗓 7 April 2026 🚀 LeetCode #703 – Kth Largest Element in a Stream Solved this problem using a clean and efficient Min Heap approach 🔥 💡 Instead of storing all elements, I maintained only the top K largest elements, which makes the solution scalable for large data streams. 🧠 Approach: • Created a min heap • Added elements in the constructor • If size exceeds k → removed the smallest element • In add(): – Push new value into heap – Pop if size exceeds k – Return the top element (Kth ) ⚡ Time Complexity: O(n log k) 📦 Space Complexity: O(k) 💭 Key Insight: We don’t need to store all elements — just maintain the top k elements. The smallest among them is the answer 🎯 #LeetCode #DSA #Python #Coding #100DaysOfCode #Heap
To view or add a comment, sign in
-
-
🚀 Solved today’s LeetCode challenge: Longest Common Prefix 💻🔥 Problem: Given an array of strings, find the longest common starting substring among all strings. ✅ Example: ["flower", "flow", "flight"] → "fl" ["dog", "racecar", "car"] → "" 🧠 My Approach: Started with the first word as a prefix and compared it with the remaining strings one by one. Whenever a mismatch happened, I kept shrinking the prefix from the end until it matched. This helped me understand: 🔹 String slicing in Python 🔹 Prefix matching logic 🔹 Edge case handling 🔹 Writing optimized clean code 💡 Time Complexity: O(n * m) (n = number of strings, m = prefix length) Consistency > Motivation. One problem every day builds strong problem-solving skills 📈 Check Out : https://lnkd.in/dtumdVUQ #LeetCode #Python #DSA #CodingJourney #ProblemSolving #100DaysOfCode #SoftwareEngineer #Programming #Tech #Learning
To view or add a comment, sign in
-
🚀 Just solved the “Valid Number” problem on LeetCode! This problem looks simple at first glance—but handling edge cases like decimals, signs, and exponents makes it a great test of attention to detail and logical thinking. ✅ Key takeaways: Careful handling of edge cases is crucial Validating input step-by-step can simplify complex parsing problems Writing clean, readable logic beats overcomplicated solutions 💡 Performance: ⚡ Runtime: 3 ms 🧠 Efficient space usage ✅ All test cases passed Problems like this remind me that consistency in practice is what builds strong problem-solving skills. On to the next one! 🔥 #LeetCode #Coding #Python #ProblemSolving #SoftwareEngineering #AIEngineerJourney link of #Solution :- https://lnkd.in/ga9b5pVb
To view or add a comment, sign in
-
-
🚀 Another LeetCode Problem Solved: Palindrome Number! 🔗 Check out my solution: https://lnkd.in/dwDMqXXn 💡 Problem Overview Given an integer x, determine whether it is a palindrome — meaning it reads the same forward and backward. (LeetCode) Examples: ✔ 121 → Palindrome ❌ -121 → Not a palindrome ❌ 10 → Not a palindrome 🧠 My Approach (Digit Reversal) Instead of converting the number to a string, I used a mathematical approach: Extract digits using % 10 Reverse the number step by step Compare reversed number with original ⚙️ Key Learnings ✔ Strong understanding of number manipulation ✔ Importance of handling edge cases (negative numbers, trailing zeros) (leet-solution.com) ✔ Practicing clean and efficient logic ⏱️ Complexity • Time Complexity: O(log n) • Space Complexity: O(1) 🔥 Why this problem matters Even though it’s an “easy” problem, it builds: Logical thinking Problem-solving fundamentals Confidence for bigger challenges #LeetCode #DSA #Python #CodingJourney #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
Day 65 – Coding Challenge 🚀 Today’s problem was an interesting mix of simulation and stack-based processing. 🔹 Problem Statement: Given an array, repeatedly apply operations on adjacent elements with opposite signs: If absolute values differ → keep the one with larger absolute value If equal → remove both Continue until no more operations can be performed. 🔹 Approach: Used a stack-like approach to simulate the process For each element: Compared with the last element in the result Resolved conflicts based on sign and absolute value Repeated merging/removal until stable Ensured the final array satisfies all conditions This problem highlights how stack-based simulation helps efficiently handle sequential conflicts and reductions. Day 66 next — let’s keep building 💪 #geekstreak60 #npci #day65 #dsa #python #codingchallenge #problemSolving #learningjourney #consistency
To view or add a comment, sign in
-
-
🚀 Day 75 of #100DaysOfCode 🔥 LeetCode 179 – Largest Number 💡 Problem: Given a list of non-negative integers, arrange them such that they form the largest possible number. 🧠 Key Insight: Normal sorting won't work here ❌ We need a custom comparator based on string concatenation. 👉 Compare: - ""a + b"" vs ""b + a"" - Whichever gives a larger value should come first. ⚙️ Approach: 1. Convert numbers to strings 2. Sort using custom comparison logic 3. Join the result 4. Handle edge case (like "[0,0] → "0"") ⚡ Complexity: - Time: O(n log n) - Space: O(n) 🎯 Result: ✅ Accepted ⚡ Runtime: 0 ms (100%) 📌 Lesson Learned: Sometimes sorting logic depends on combination, not value. #LeetCode #Python #CodingJourney #DSA #100DaysOfCode #Sorting #ProblemSolving
To view or add a comment, sign in
-
-
LeetCode Day 13 – Container With Most Water Today I solved the classic “Container With Most Water” problem — a great example of optimizing from brute force to an efficient solution! Problem Insight: We are given an array of heights, and we need to find two lines that together with the x-axis form a container that holds the maximum water. Approaches: Brute Force (O(n²)) Check all possible pairs Calculate area = width × min(height[i], height[j]) Keep track of maximum Optimal Approach – Two Pointer (O(n)) Start with two pointers at both ends Calculate area Move the pointer with smaller height inward Repeat until pointers meet Key Idea: The limiting factor is always the smaller height Moving the larger height won’t help increase area Complexity: Time: O(n) Space: O(1) What I learned: How two-pointer technique drastically reduces complexity Importance of understanding constraints before coding #LeetCode #Day13 #DSA #CodingJourney #Python #TwoPointers #ProblemSolving
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