Day 25/100 – LeetCode Challenge 🚀 Problem: Plus One Approach: Traversed digits from right to left Handled carry when the digit was 9 Created a new array only when all digits were 9 Time Complexity: O(n) Space Complexity: O(1) Key takeaway: Many array problems that involve arithmetic operations require careful carry handling from the end of the array. #LeetCode #100DaysOfCode #DSA #Java #ProblemSolving #InterviewPrep
Muthu Suresh’s Post
More Relevant Posts
-
Day 13/100 – LeetCode Challenge 🚀 Solved Count Binary Substrings using an optimized O(n) approach by grouping consecutive characters and comparing segment lengths. Key takeaway: Instead of generating all substrings, identify patterns and reduce the problem to counting adjacent groups. Consistency > Motivation 💪 #100DaysOfCode #DSA #Java #LeetCode
To view or add a comment, sign in
-
-
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 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
-
-
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 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 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 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
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 30 of My LeetCode Journey Today I solved LeetCode 451 – Sort Characters By Frequency. 🔹 Problem Statement: Given a string s, sort the characters in decreasing order based on their frequency. 🔹 Approach (HashMap + Max Heap): 1️⃣ Use a HashMap to count the frequency of each character. 2️⃣ Use a Priority Queue (Max Heap) to sort characters by their frequency. 3️⃣ Extract characters from the heap and append them to the result string according to their frequency. ⏱ Time Complexity: O(n log k) 📦 Space Complexity: O(n) This problem helped me strengthen my understanding of HashMap, Priority Queue (Max Heap), and frequency-based sorting. #LeetCode #DSA #Java #CodingJourney #ProblemSolving
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