#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
Search 2D Matrix with Binary Search
More Relevant Posts
-
Day-28 Solved the Count and Say problem today and it turned out to be a really good exercise in string manipulation. 👉 The idea is simple: start with "1" and keep generating the next term by describing the previous one. 👉 You only count consecutive digits, not overall frequency. 👉 Example: "1" → "11" → "21" → "1211" 💡 What I learned: Always think in terms of patterns Handle edge cases carefully (especially index bounds ⚠️) Small bugs like accessing i+1 without checking can break everything 🛠️ Concepts used: Strings Loops to_string() It looked confusing at first, but once the pattern clicked, it became straightforward. #leetcode #cpp #dsa #coding #learning
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
-
-
#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
-
-
🌟 Day 181 ✅ #LoveBabbar Sheet 🌟 ❓ Minimum edges If a graph has N nodes, the minimum edges required to keep it connected are: E_{min}=N-1 📌 This forms a Tree (connected graph with no cycles). Key points: • Edges < N−1 → Graph cannot be connected • Edges = N−1 → Tree • Edges > N−1 → Cycles possible #DSA #Graphs #Trees #CompetitiveProgramming #Coding #minimumedges
To view or add a comment, sign in
-
-
#100DaysLeetCode Day 40 ✅ Solved LeetCode 16: 3Sum Closest Given an array and a target value, find the sum of three integers that is closest to the target. 🚀 Approach Used Sorting + Two Pointers Steps: Sort the array Fix one element Use two pointers (left and right) to find the closest sum Logic: If current sum is closer to target than previous result → update answer If sum < target → move left Else → move right If sum becomes exactly equal to target, return immediately. ⏱ Complexity Time Complexity: O(n²) Space Complexity: O(1) (ignoring sorting space) #100DaysLeetCode #Day40 #LeetCode16 #leetcode #cpp #dsa #twopointers #arrays #problemSolving #coding #interviewprep
To view or add a comment, sign in
-
-
🗓 Day 9/100 – DSA Challenge Problem: Maximum Product of Two Elements in an Array (LeetCode #1464) 🎯 Goal: Find the maximum value of (nums[i] - 1) * (nums[j] - 1) for two different indices. 💡 Key Notes: Brute Force: Check all pairs → O(n2) O(n2) Optimized: Find top 2 largest numbers in one pass → O(n) O(n) Handles negative values and duplicates. Growing one problem at a time 💪 #100DaysOfCode #LeetCode #DSA #CodingChallenge
To view or add a comment, sign in
-
-
#Day550 of #600DaysOfDSA Topics and Learnings: #BinarySearch Problems Re-revised: 170. #Leetcode #1283 : Find the Smallest Divisor Given a Threshold Approach: Used Binary Search to solve this Complexity Analysis: TC: O(log(max)*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
-
-
#Day523 of #600DaysOfDSA Topics and Learnings: #Recursion Problems Re-revised: 143. #LeetCode #282 : Expression Add Operators Approach: Used #Recursion to solve this Complexity Analysis: TC: O(4^N) SC: O(N) #600DaysLeetCodeChallenge #600DaysLeetCode #DataStructures #Algorithms #ProblemSolving #DSA #LeetCode #TakeUForward #TUF+ #SoftwareDevelopment #ContinuousLearning #ProfessionalGrowth #Coding
To view or add a comment, sign in
-
-
#Day534 of #600DaysOfDSA Topics and Learnings: #MergeSort Problems Re-revised: 154. #LeetCode #493 : Reverse Pairs Approach: Used #MergeSort to solve this Complexity Analysis: TC: O(N * logN) SC: O(N) #600DaysLeetCodeChallenge #600DaysLeetCode #DataStructures #Algorithms #ProblemSolving #DSA #LeetCode #TakeUForward #TUF+ #SoftwareDevelopment #ContinuousLearning #ProfessionalGrowth #Coding
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