Day 12 of #100DaysOfLeetCode Problem: 26. Remove Duplicates from Sorted Array Category: Arrays / Two Pointers Today’s problem was about removing duplicates from a sorted array in-place, ensuring each element appears only once and returning the new length. This problem was a great way to strengthen my understanding of two-pointer traversal and array updates without extra space. 🧠 Key Learnings: Used one pointer to track the position of the last unique element while iterating through the array. When a new unique value was found, it was placed at the next available position. Improved confidence in working with in-place modification techniques. Learned to think efficiently — no need for extra arrays or memory allocation. 🎯 Takeaway: Understanding how to manipulate arrays in-place is key to writing space-optimized and interview-ready code. #LeetCode #100DaysOfCode #ProblemSolving #CodingJourney #Arrays #TwoPointers #Python #AIEngineer #Consistency
Solved LeetCode 26: Remove Duplicates from Sorted Array
More Relevant Posts
-
Day 3 of #100DaysOfLeetCode Problem: 167. Two Sum II – Input Array Is Sorted Category: Arrays / Two Pointers Today’s challenge was all about finding two numbers in a sorted array that add up to a given target. Since the array is already sorted, using two pointers gives an elegant O(n) solution — no need for extra space! 🧠 Key Learnings: Initialized pointers at both ends (l = 0, r = n-1). If the sum is smaller than the target → move left pointer rightward. If the sum is greater → move right pointer leftward. Found the exact indices in linear time using smart pointer movement. 💡Time Complexity: O(n) 💡 Space Complexity: O(1) 🎯 Takeaway: When the array is sorted, two pointers can replace complex hash-based logic, simplifying both time and space usage. Staying consistent and learning one problem at a time! 💪 #LeetCode #100DaysOfCode #ProblemSolving #CodingJourney #Arrays #TwoPointers #Python #AIEngineer #Consistency
To view or add a comment, sign in
-
-
Today I explored NumPy, one of the most powerful library of Python for numerical and scientific computing. Here’s what I practiced: Creating arrays with np.array() Using functions like zeros(), ones(), arange(), eye(), and linspace() Checking dimensions with .ndim Understanding array shapes using .shape I’m really enjoying how NumPy makes working with data so much easier and faster. #Python #NumPy #DataScience #LearningJourney #PythonForDataScience
To view or add a comment, sign in
-
Day 11 of #100DaysOfLeetCode Problem: 14. Longest Common Prefix Category: Strings / Comparison / Iteration Today’s challenge focused on finding the longest common prefix among an array of strings. It’s a great problem that improves your understanding of string traversal, comparison, and boundary conditions. 🧠 Key Learnings: Iterated character by character through the first string and compared it with all other strings. Carefully handled edge cases where strings had different lengths or no common prefix. Reinforced the concept of early termination when a mismatch is found — improving efficiency. Strengthened skills in iterative string comparison and control flow logic. 🎯 Takeaway: Small details like string length and early exit conditions make a big difference in optimizing even the simplest problems. #LeetCode #100DaysOfCode #ProblemSolving #CodingJourney #Strings #Python #AIEngineer #Consistency
To view or add a comment, sign in
-
-
#Day20 #100DaysOfCode 🧩 Problem: Given a matrix where each row and column is sorted in increasing order, determine whether a given element x exists in the matrix. 💡 Approach: Instead of searching every element, I used an optimized O(n + m) approach — starting from the top-right corner and moving left or down based on comparisons. #100DaysOfCode #Day20 #Python #CodingChallenge #DataStructures #Algorithms #Matrix #SearchAlgorithm #ProblemSolving
To view or add a comment, sign in
-
-
Day 49: Mastering State Control. This penultimate day of the 50-day campaign was focused on achieving technical mastery over mutable objects in Python, differentiating the operational impact of .pop() versus .remove(), and leveraging .append() versus .extend() for structured list growth. This deep command ensures predictable code flow, and having refined this essential toolkit, I am fully prepared to apply this precision to the final complexities of the challenge ahead. #NxtWave #Python #50DayChallenge #CodeControl #ProfessionalCoding
To view or add a comment, sign in
-
Day 41 of #180DaysOfCode Today, I leveled up the 𝗿𝗼𝘁𝗮𝘁𝗲𝗱 𝘀𝗼𝗿𝘁𝗲𝗱 𝗮𝗿𝗿𝗮𝘆 𝗽𝗿𝗼𝗯𝗹𝗲𝗺: 𝗦𝗲𝗮𝗿𝗰𝗵 𝘄𝗶𝘁𝗵 𝗗𝘂𝗽𝗹𝗶𝗰𝗮𝘁𝗲𝘀! 🔍 When the array contains duplicates, the previous approach needed a tweak. If nums[low] == nums[mid] == nums[high], we can't decide which side is sorted. The solution? Trim duplicates by moving low and high inward, then proceed with the standard rotated search logic. This ensures we still achieve O(log n) performance in most cases, though it can degrade to O(n) with many duplicates. A subtle but important edge case that makes binary search even more interesting! #Python #Algorithms #BinarySearch #RotatedArray #Duplicates #Coding
To view or add a comment, sign in
-
-
💡 Creating Arrays using NumPy! Just explored how to create and manipulate different types of arrays using NumPy — from 1D to multidimensional arrays, along with functions like arange(), zeros(), ones(), and linspace(). This helped me understand how NumPy makes numerical operations faster and more efficient. ⚡📊 🔗 GitHub Repository: https://lnkd.in/gsPj_hxs 👨🏫 Under the guidance of: Ashish Sawant #NumPy #Python #DataScience #MachineLearning #CodingJourney #LearningEveryday
To view or add a comment, sign in
-
Day 9 of #30DaysOfCode | LeetCode Problem 3. Longest Substring Without Repeating Characters Implemented an optimized Sliding Window approach to find the length of the longest substring without repeating characters. By maintaining a dynamic window using two pointers and a hash set, the algorithm achieves O(n) time complexity while efficiently managing unique character sequences. #Python #LeetCode #CodingChallenge #ProblemSolving #DataStructures #Algorithms #DSA
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