LeetCode #11 - Container With Most Water Two Pointer Approach | Time Complexity: O(n) linear time complexity This problem is a great example of how the Two-POinter technique can turn an O(n^2) brute force approach into an efficient O(n) solution. The Idea: 1. Start with two pointer at both ends 2. Move the smaller height pointer inward 3. Keep track of the maximum area #LeetCode #DSA #Coding #programming #ProblemSolving #TwoPonters #CPP #Prepration #DataStructure #Algorithm #LateNight
LeetCode #11: Two Pointer Approach for Max Area
More Relevant Posts
-
On Day 286 of my #300daysofcode challenge, I'm sharing my solution to LeetCode Problem 3461, "Maximum Length of Semi-Decreasing Subarrays." This problem is a good reminder that a simple brute-force approach is often the most direct and effective solution for smaller constraints or as a foundational step before optimization. My video provides a clear walkthrough of this logical method. #DataStructures #Algorithms #LeetCode #CodingInterview #Programming #ProblemSolving #300daysofcode
To view or add a comment, sign in
-
📅 Day 35 of #100DaysOfCode Problem: Search in Rotated Sorted Array II (LeetCode 81) Approach: 1️⃣ First, handled duplicates by skipping consecutive equal elements from both ends to avoid confusion while finding the rotation point. 2️⃣ Used a modified binary search to find the pivot (the smallest element’s index) — this separates the rotated parts of the array. 3️⃣ Performed binary search on both halves — before and after the pivot — to check where the target lies. 4️⃣ Returned true if found in either part, else false. #100DaysOfCode #LeetCode #BinarySearch #RotatedArray #ProblemSolving #Algorithms #DSA #Cplusplus #CodingChallenge #Programming #DeveloperLife #CodeNewbie #DailyDSA #TechCommunity #KeepLearning #SoftwareEngineering #LearningInPublic #Motivation
To view or add a comment, sign in
-
-
📅 Day 33 of #100DaysOfCode Problem: Basic Calculator (LeetCode 224) Approach: 1️⃣ Parsed the string character by character, keeping track of current number, sign, and result. 2️⃣ When encountering '+' or '-', added the previous number to the result and reset the current number. 3️⃣ Used a stack to handle parentheses — pushed the current result and sign when '(' was found, then restored them after ')'. 4️⃣ Carefully computed the final result by adding the last pending number after traversal. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Stack #Cplusplus #CodingChallenge #Algorithms #Math #CodeNewbie #Programming #SoftwareEngineering #CodingJourney #TechCommunity #DeveloperLife #KeepLearning #LearningInPublic #Motivation
To view or add a comment, sign in
-
-
📅 Day 32 of #100DaysOfCode Problem: Design HashSet (LeetCode 705) Approach: 1️⃣ Used a boolean vector of fixed size (1,000,001) to represent presence or absence of elements directly by index. 2️⃣ add(key) marks the key as true, meaning it’s present in the set. 3️⃣ remove(key) simply resets the value to false. 4️⃣ contains(key) checks presence in O(1) time using direct indexing — super efficient and clean! #100DaysOfCode #LeetCode #DSA #ProblemSolving #Cplusplus #CodingChallenge #HashSet #DataStructures #Algorithms #CodeNewbie #Programming #DeveloperLife #SoftwareEngineering #LearningInPublic #TechCommunity #KeepLearning #CodingJourney #Motivation #Efficiency
To view or add a comment, sign in
-
-
On Day 290 of my #300daysofcode challenge, I'm sharing my solution to LeetCode Problem 1526, "Minimum Number of Increments on Subarrays to Form a Target Array." This problem is a brilliant application of the greedy algorithm and differential thinking. My video provides a clear walkthrough of this elegant approach, which is a valuable skill for technical interviews and a great way to think about optimization in sequential operations. #DataStructures #Algorithms #LeetCode #CodingInterview #Programming #GreedyAlgorithm #300daysofcode
To view or add a comment, sign in
-
🚀 LeetCode Daily Challenge – Day 4 (November 2025) 🧩 Problem: 3318. Find X-Sum of All K-Long Subarrays I 📚 Topic: Arrays | Sliding Window | HashMap | Prefix Sum 🔍 Approach: Used a sliding window of size k to compute the X-sum for each subarray. Maintained frequency counts of elements within the window and dynamically updated the sum as elements entered and left the window. This approach efficiently avoids recalculating sums from scratch for every subarray. ✅ Time Complexity: O(n) ✅ Space Complexity: O(k) 💡 Key Takeaway: Sliding window problems reinforce how optimizing repetitive computations can drastically improve performance — small logic, big impact! ⚡ #LeetCode #LeetcodeDailyChallenge #Coding #DSA #SlidingWindow #Array #HashMap #Day4 #Programming #Engineering
To view or add a comment, sign in
-
-
On Day 292 of my #300daysofcode challenge, I'm sharing my solution to LeetCode Problem 37, "Sudoku Solver." This problem is a textbook example of a constraint satisfaction problem solved via Backtracking. My video provides a clear walkthrough of the recursive logic and the crucial board validation steps, which is a valuable skill for advanced technical interviews and mastering recursive algorithms. #DataStructures #Algorithms #LeetCode #CodingInterview #Programming #Backtracking #300daysofcode
To view or add a comment, sign in
-
On Day 296 of my #300daysofcode challenge, I'm sharing my solution to LeetCode Problem 154, "Find Minimum in Rotated Sorted Array II." This problem tests the limits of Binary Search when duplicates are present. My video provides a clear walkthrough of the modified search logic, which is a valuable skill for advanced technical interviews, demonstrating proficiency in handling edge cases within core algorithms. #DataStructures #Algorithms #LeetCode #CodingInterview #Programming #BinarySearch #300daysofcode
To view or add a comment, sign in
-
🔥 LeetCode POTD: Number of Substrings With Only 1s Today’s question was actually on the easier side… once you notice the key detail: it’s a binary string 👀. Here’s how my thought process went ⬇️ At first, I considered generating all substrings and then checking which ones contain only 1s. But of course… generating + checking = ❌ higher time complexity, which breaks the constraints. Not ideal. Then I took a step back and realized: 👉 Since it's a binary string, the substrings made of only 1s form clear continuous blocks. 👉 For each block of consecutive 1s of length k, the number of valid substrings is: k × (k + 1) / 2 ✨ Using this pattern, the whole problem can be solved in O(n) time. Dropped my solution in the image below 📸 Would love to hear how you approached it! 😄💬 #leetcode #leetcodechallenge #dsa #coding #programming #problemsolving #binarystrings
To view or add a comment, sign in
-
-
📅 Day 51 of #100DaysOfCode Problem: Number of Substrings That Satisfy (LeetCode 3280) Approach: 1️⃣ Precomputed cumulative counts of 1s using a prefix sum array. 2️⃣ For each substring [i...j], calculated both the number of 0s and 1s. 3️⃣ Used a smart optimization: If (zero² > one), skip forward — those substrings can’t satisfy the condition. If (zero² == one) or (zero² < one), count and move ahead efficiently. 4️⃣ This drastically reduced redundant iterations compared to a naïve O(n³) brute force. #100DaysOfCode #LeetCode #DSA #ProblemSolving #Cplusplus #CodingChallenge #Algorithms #MathLogic #BinaryString #Programming #DeveloperLife #CodingJourney #CodeNewbie #DailyDSA #SoftwareEngineering #KeepLearning #GrowthMindset #Motivation #TechCommunity
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