Day 08 of #50DaysOfCode Today’s problem: Move Zeroes (LeetCode) Problem Statement: Move all 0s to the end of the array while maintaining the relative order of non-zero elements — all done in-place. Approach: Used the Two Pointer Technique to efficiently rearrange elements in a single pass without extra space. Key Insight: Track the position of the next non-zero element and swap only when necessary. 🔹 Complexity: ⏱ Time: O(n) 📦 Space: O(1) 🔹 Learning Outcome: Improved understanding of in-place array manipulation and optimized swapping logic. #LeetCode #Python #DataStructures #CodingJourney #ProblemSolving #100DaysOfCode #DeveloperLife
Move Zeroes in Array with Two Pointer Technique
More Relevant Posts
-
🚀 Day 33 – LeetCode Journey Today’s problem: Move Zeroes ✔️ Used two-pointer technique for in-place modification ✔️ Moved all non-zero elements forward efficiently ✔️ Maintained relative order of elements 💡 Key Insight: By keeping a pointer for non-zero elements, we can swap values in a single pass and avoid extra space — making the solution both clean and optimal. This problem improved my understanding of array manipulation and in-place algorithms. Consistency is building confidence day by day 💪🔥 #LeetCode #Day33 #Arrays #TwoPointers #Python #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 40 – LeetCode Journey Today’s problem: Linked List Cycle ✔️ Solved using Floyd’s Cycle Detection Algorithm (Tortoise & Hare) ✔️ Used two pointers (slow & fast) ✔️ Efficient cycle detection without extra space 💡 Key Insight: If a cycle exists, the fast pointer will eventually meet the slow pointer. This approach avoids using extra memory and works in O(n) time. This problem strengthened my understanding of linked lists and pointer techniques. 40 days of consistency — getting stronger every day 💪🔥 #LeetCode #Day40 #LinkedList #TwoPointers #Python #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 32 – LeetCode Journey Today’s problem: Reverse String II ✔️ Implemented in-place string reversal using two pointers ✔️ Efficiently processed the string in chunks of 2k ✔️ Optimized approach with minimal extra space 💡 Key Insight: Instead of reversing the entire string, we only reverse the first k characters in every 2k block. Using the two-pointer technique makes this both simple and efficient. This problem strengthened my understanding of string manipulation, indexing, and in-place operations. Step by step, becoming a better problem solver 🔥💪 #LeetCode #Day32 #Strings #TwoPointers #Python #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 62 of #100DaysOfCode Solved “Remove Nth Node From End of List” 🔗 💡 Today’s focus: Two Pointer Technique (Fast & Slow pointers) Instead of calculating length, I used an efficient one-pass approach to remove the target node. 🧠 Key Learnings: Dummy node helps handle edge cases (like removing head) Fast pointer moves n steps ahead Then move both pointers until fast reaches the end Slow pointer lands just before the node to delete ⚡ Clean, efficient & optimal solution (O(n) time, O(1) space) Consistency is starting to feel powerful now 💪 #DSA #LeetCode #CodingJourney #LinkedInLearning #100DaysOfCode #Day62 #Python #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 48 – LeetCode Journey Today’s challenge: Substring with Concatenation of All Words ✔️ Solved using sliding window + hashmap ✔️ Processed string in fixed-length chunks ✔️ Tracked word frequency efficiently 💡 Key Insight: Instead of checking every substring blindly, splitting the string into word-sized pieces and using a hashmap helps validate matches efficiently. Sliding window keeps the solution optimized. This problem was a great exercise in string manipulation, hashing, and window techniques 🧠 Consistency is the real game changer 🚀 #LeetCode #Day48 #SlidingWindow #HashMap #Strings #Python #ProblemSolving #CodingJourney #100DaysOfCode https://lnkd.in/gxf4RBT6
To view or add a comment, sign in
-
🚀 Day 41 – LeetCode Journey Today’s problem: Add Binary ✔️ Implemented binary addition manually ✔️ Handled carry propagation efficiently ✔️ Worked with string manipulation and indexing 💡 Key Insight: Binary addition follows the same rules as decimal addition, but with base 2. Managing the carry correctly is the key to building the final result. This problem improved my understanding of bit-level operations and string handling. Step by step, mastering the fundamentals 🔥💪 #LeetCode #Day41 #Binary #Strings #Python #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
#𝐃𝐚𝐲𝟏𝟐 – 𝐃𝐞𝐭𝐞𝐜𝐭 𝐂𝐲𝐜𝐥𝐞𝐬 𝐢𝐧 𝟐𝐃 𝐆𝐫𝐢𝐝 🚀 📝 Find a cycle of same character (length ≥ 4) in grid. 💡 Approach: DFS + Parent Tracking Visit each cell, explore neighbors with same char If visited neighbor ≠ parent → cycle found ✅ 🔧 Key: Track parent to avoid false 2-step cycles. ⏱️ O(m×n) time | O(m×n) space Cycle detection made simple! 🎯 #LeetCode #Python #100DaysOfCode #DFS #CycleDetection
To view or add a comment, sign in
-
-
Day 51 of #GeekStreak60 🚀 Today’s problem was about finding an increasing subsequence of size 3 📈 🧠 Core Idea For every element, check if there’s a smaller element before it and a greater element after it. 💡 What I Did → Precomputed: • smaller[] → index of smaller element on the left • greater[] → index of greater element on the right → Scanned the array to find a valid triplet efficiently 📚 What I Learned This problem showed how preprocessing arrays can simplify sequence problems and help achieve linear time complexity ⚡ ✅ Day 51 complete Beyond 50 and still going strong 💪🔥 #GeekStreak60 #GeeksforGeeks #NPCI #Day51 #ProblemSolving #Python #CodingJourney
To view or add a comment, sign in
-
-
Day 27/100 – DSA Practice Solved LeetCode 459: Repeated Substring Pattern today. Key Insight: If a string s is formed by repeating a substring, then it will always exist inside: (s + s)[1:-1] Why this works: Doubling the string generates all possible rotations Removing first & last characters avoids trivial matches If s is found in this modified string, it confirms a repeating pattern This elegant trick reduces the problem to a simple one-liner and highlights the power of pattern observation in strings. Approach Used: return s in (s + s)[1:-1] Constant progress > Perfection. On to the next one! #Day27 #100DaysOfCode #DSA #LeetCode #Python #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 LeetCode Progress Update – Problem Solved! ✅ Problem: Remove Trailing Zeros From a String 💡 Approach: Used reverse traversal to find the first non-zero digit and sliced the string accordingly. 🔍 Key Learning: Efficient string manipulation can avoid unnecessary conversions. Traversing from the end helps solve trailing-based problems quickly. 💻 Code Insight: Instead of removing zeros one by one, I identified the breakpoint and sliced the string — making it optimal and clean. ⏱️ Performance: Runtime: 3 ms ⚡ Beat: 66%+ users Memory: 19.23 MB 📈 Consistency is key — one problem closer to mastery! #LeetCode #CodingJourney #Python #ProblemSolving #DSA #100DaysOfCode
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