Day 23 of #100DaysOfCode: #DSA: Stack: 1. Simple Stack 2. Monotonic stack: Stores items in sorted order(strictly increasing/decreasing) 3. Greedy Stack: pop/push based on greedy decisions to build an optimal result. Leetcode Problem: - Remove All Adjacent Duplicates(1047) approach: - use stack - assume first item is unique and add it to the stack - now iterate over the string - if stack top == current char then pop (it's adjacent and duplicate remove them) - else push current char - build final string from the stack and return it Time Complexity: O(n) Space Complexity: O(n) #Coding #CodingJourney
Day 23: LeetCode 1047 - Remove Adjacent Duplicates with Stack
More Relevant Posts
-
Solved Reverse Linked List II today. The problem involves reversing a portion of a linked list between two given positions while keeping the rest of the list unchanged. It was a good exercise in careful pointer manipulation and handling edge cases when working with linked lists. Problems like this help strengthen understanding of how linked list operations actually work under the hood. #LeetCode #LinkedList #ProblemSolving #Coding
To view or add a comment, sign in
-
-
🚀 Day 5/60 — LeetCode Discipline Problem Solved: Range Sum Query – Immutable (Revision) Difficulty: Easy Today’s practice was centered around strengthening prefix sum intuition for efficient range queries. Instead of recalculating sums repeatedly, the focus was on preprocessing the array to enable constant-time query responses. 💡 Focus Areas: • Reinforced prefix sum technique • Practiced preprocessing for query optimization • Improved time–space trade-off understanding • Focused on writing clean and efficient logic ⚡ Performance Highlight: Achieved ~99% runtime efficiency on submission. Quiet, consistent refinement of core patterns continues. #LeetCode #60DaysOfCode #100DaysOfCode #DSA #PrefixSum #Algorithms #DataStructures #ProblemSolving #CodingJourney #SoftwareEngineering #TechCareers #Programming #Developers #CodingLife
To view or add a comment, sign in
-
-
#100DaysLeetCode Day 27 ✅ Solved LeetCode 852: Peak Index in a Mountain Array A mountain array increases first and then decreases. The task is to find the peak element index. 🚀 Approach: Used Binary Search to efficiently locate the peak. Key idea: If arr[mid] < arr[mid + 1] → we are on the increasing slope, move right Otherwise → we are on the decreasing slope or peak, move left Continue shrinking the search space until low == high. That index is the peak of the mountain. ✅ Time Complexity: O(log n) ✅ Space Complexity: O(1) #100DaysLeetCode #Day27 #LeetCode852 #leetcode #cpp #dsa #binarysearch #problemSolving #coding #interviewprep #placements
To view or add a comment, sign in
-
-
#Day42 Of #100DaysOfCode: #DSA: solve leetcode problem - Search a 2D Matrix II simple approach: - start from matrix[last_row][first_col] - check if matrix[row][col] > target then go up means row--; - else if matrix[row][col] < target then go right means col++; - else means matrix[row][col] == target -> return true; - int the last return false it will only run when the loop does't return Time: O(m + n) space: O(1) #DSA #Coding #Daily #Leetcode #CodingJourney #Learning
To view or add a comment, sign in
-
-
JSON tags let you control how struct fields become JSON keys. Add omitempty and Go skips the field when it has its zero value. Without it, an empty string becomes "", a zero int becomes 0, and that might not be what you want. With omitempty, the field disappears from the output entirely. This is useful for optional fields. A product might not have a price yet. A user might not have an email. Omitempty keeps your JSON clean and avoids sending zero values that could be ambiguous. Follow me for more Go bytes #golang #golangtips #goprogramming #coding #softwaredevelopment
To view or add a comment, sign in
-
-
#Day41 of #100DaysOfCode: #DSA: Solve leetcode problem - Search a 2D Matrix(74) simple approach: Performing binary search twise: first time to find the row, then second time to find the element within that row. Time: O(log (M * N)) Space: O(1) #Coding #Daily #ProblemSoliving #Learning #CodingJourney #DSA
To view or add a comment, sign in
-
-
Day 42 on LeetCode — Merge Sorted Array (Two Pointer Approach) ✅ Today’s problem focused on efficient in-place array manipulation using the two-pointer technique. 🔹 Approach Used in My Solution The key insight was to compare elements from the back of both arrays instead of the front. Since nums1 already has extra space at the end to accommodate elements from nums2, we can fill the array from the last index backwards. Key points in the logic: • Initialize pointers at the end of the valid elements of nums1 and nums2 • Compare the elements and place the larger one at the back of nums1 • Move the pointers accordingly until all elements are merged • This allows the final sorted array to be stored directly in nums1 This strategy avoids unnecessary shifting of elements and keeps the solution efficient. ⚡ Complexity: • Time Complexity: O(m + n) • Space Complexity: O(1) (in-place merge) 💡 Key Takeaways: • Learned how working from the back can simplify in-place merges • Strengthened understanding of the two-pointer technique • Practiced optimizing array operations without using extra space #LeetCode #DSA #Algorithms #DataStructures #TwoPointers #Arrays #ProblemSolving #Coding #Programming #Cpp #STL #SoftwareEngineering #ComputerScience #CodingPractice #DeveloperLife #TechJourney #CodingDaily #100DaysOfCode #BuildInPublic #AlgorithmPractice #CodingSkills #Developers #TechCommunity #SoftwareDeveloper #EngineeringJourney
To view or add a comment, sign in
-
-
#100DaysLeetCode Day 33 ✅ Solved LeetCode 540: Single Element in a Sorted Array In a sorted array where every element appears twice except one, the task is to find that single element. 🚀 Approach Used Binary Search with index pattern observation. Key idea: In a valid pair structure, elements appear in pairs like: (even index, odd index) → before the single element After the single element, this pattern breaks Steps: Ensure mid is even If nums[mid] == nums[mid + 1] → single element is on the right side Otherwise → it lies on the left side (including mid) Shrink the search space until low == high. Time Complexity: O(log n) Space Complexity: O(1) #100DaysLeetCode #Day33 #LeetCode540 #leetcode #cpp #dsa #binarysearch #problemSolving #coding #interviewprep
To view or add a comment, sign in
-
-
#Day532 of #600DaysOfDSA Topics and Learnings: #KadaneAlgorithm Problems Re-revised: 152. #LeetCode #152 : Maximum Product Subarray Approach: Used #KadaneAlgorithm to solve this Complexity Analysis: TC: O(N) SC: O(1) #600DaysLeetCodeChallenge #600DaysLeetCode #DataStructures #Algorithms #ProblemSolving #DSA #LeetCode #TakeUForward #TUF+ #SoftwareDevelopment #ContinuousLearning #ProfessionalGrowth #Coding
To view or add a comment, sign in
-
-
You will see http.Error in a lot of Go HTTP code. It is worth knowing what it does under the hood. It is not magic. It uses the same response writer you already have: it calls WriteHeader to send the status code, then writes the message as the response body. So the client gets a normal HTTP response with an error status and a plain text message. Once you see that it is just those two steps, error responses make sense. Follow me for more Go bytes #golang #golangtips #goprogramming #coding #softwaredevelopment
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