Day 26/100 – LeetCode Challenge 🚀 Problem: Remove Duplicates from Sorted List Approach: Traversed the linked list using a pointer Compared each node with its next node Skipped the next node whenever duplicate values were found Time Complexity: O(n) Space Complexity: O(1) Key takeaway: When a linked list is sorted, duplicate removal becomes a simple one-pass pointer manipulation problem. #LeetCode #100DaysOfCode #DSA #Java #LinkedList #ProblemSolving
Remove Duplicates from Sorted Linked List in Java
More Relevant Posts
-
Day 30/100 – LeetCode Challenge 🚀 Problem: Count Binary Substrings Approach: Counted consecutive groups of 0’s and 1’s For every adjacent pair of groups, added min(prevGroup, currGroup) to the result Avoided generating substrings explicitly Time Complexity: O(n) Space Complexity: O(1) Key takeaway: Many substring problems don’t require generating substrings — they can be solved by analyzing group patterns and transitions. #LeetCode #100DaysOfCode #DSA #Java #Strings #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 3 of #100DaysOfCode – LeetCode Journey Solved: Running Sum of 1D Array (Java) Today’s focus was on understanding prefix sums and improving array manipulation skills. It’s a simple problem, but it reinforces an important concept used in many advanced algorithms. Small steps every day → Strong foundations over time. Consistency > Motivation. 🔗 GitHub: https://lnkd.in/gd4KSCzz #DSA #Java #LeetCode #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 12/100 – LeetCode Challenge Problem: Middle of the Linked List Today’s problem focused on finding the middle node of a singly linked list. Approach: Used the Two-Pointer Technique (Slow & Fast pointers). slow moves one step at a time fast moves two steps at a time When fast reaches the end of the list, slow will be at the middle node Complexity: Time: O(n) Space: O(1) Concepts Practiced: Linked List traversal Two-pointer technique Efficient single-pass solution #100DaysOfCode #LeetCode #DSA #Java #LinkedList #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 35/100 – LeetCode Challenge 🚀 Problem: 3Sum Approach: Sorted the array Fixed one element and used two pointers for the remaining two Skipped duplicates to ensure unique triplets Used early stopping when the current number became positive Time Complexity: O(n²) Space Complexity: O(1) Key takeaway: Many 3-element sum problems reduce to sorting + two-pointer pattern. #LeetCode #100DaysOfCode #DSA #Java #TwoPointers #ProblemSolving #InterviewPrep
To view or add a comment, sign in
-
-
Day 36/100 – LeetCode Challenge 🚀 Problem: 3Sum Closest Approach: Sorted the array Fixed one element and applied the two-pointer technique Tracked the closest sum by comparing absolute differences Returned immediately if an exact match was found Time Complexity: O(n²) Space Complexity: O(1) Key takeaway: Many optimization problems are variations of classic patterns. Understanding 3Sum deeply makes solving 3Sum Closest straightforward. #LeetCode #100DaysOfCode #DSA #Java #TwoPointers #ProblemSolving #InterviewPrep
To view or add a comment, sign in
-
-
Solved "Container With Most Water" on LeetCode today using the Two-Pointer Technique. 🚀 The key insight is that the area formed by two lines depends on the shorter height and the distance between them. Starting with pointers at both ends of the array, we compute the area and move the pointer at the smaller height inward to potentially find a taller boundary and maximize the area. This approach efficiently reduces the problem from O(n²) brute force to O(n) time with O(1) space. Problems like this are a great reminder that the right observation can drastically optimize a solution. 💡 #LeetCode #DSA #TwoPointers #Java #ProblemSolving
To view or add a comment, sign in
-
-
Day 34/100 – LeetCode Challenge 🚀 Problem: Container With Most Water Approach: Used two pointers (left & right) Calculated area using min(height[left], height[right]) × width Moved the pointer pointing to the smaller height Updated maximum area during traversal Time Complexity: O(n) Space Complexity: O(1) Key takeaway: When maximizing area between two boundaries, moving the smaller boundary is the only way to potentially increase the result. #LeetCode #100DaysOfCode #DSA #Java #TwoPointers #ProblemSolving
To view or add a comment, sign in
-
-
Day 9/100 – LeetCode Challenge Problem: 3Sum Today’s challenge was to find all unique triplets in an array whose sum equals 0. Approach: Sort the array to efficiently apply the two-pointer technique. Fix one element nums[i] and use two pointers (left and right) to find the remaining two numbers. If the sum equals 0, store the triplet. Skip duplicate elements to ensure only unique triplets are included. Key Idea: Sorting + Two Pointers helps reduce the brute-force O(n³) approach to O(n²). Concepts Practiced: Sorting Two-pointer technique Duplicate handling Array traversal optimization #100DaysOfCode #LeetCode #DSA #Java #TwoPointers #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 22/30 – Remove Nth Node From End of List Solved a classic Linked List problem today. Approach: • Use Two Pointers (Fast & Slow) • Move fast pointer n+1 steps ahead • Move both pointers until fast reaches the end • Slow pointer will be right before the node to remove Time Complexity: O(n) Space Complexity: O(1) Key concept: Two-pointer technique with a dummy node. #30DaysOfDSA #Java #LinkedList #CodingChallenge
To view or add a comment, sign in
-
-
🚀 Day 20 – #100DaysOfLeetCode Today’s problem: Product of Array Except Self (Medium) 🔹 Learned how to solve it in O(n) time 🔹 Without using division 🔹 Optimized space complexity The key idea was using prefix and suffix products instead of recalculating product every time. #Day20 #LeetCode #DSA #Java #CodingJourney
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