Day 14/100 | #100DaysOfDSA Today’s problem: Search a 2D Matrix At first glance, it looks like a 2D search problem… But the trick? Treat the matrix like a sorted 1D array. Since: • Each row is sorted • First element of every row > last element of previous row That means the entire matrix is globally sorted. Approach: • Apply Binary Search • Convert mid index → row = mid / n, col = mid % n • Compare and adjust pointers Time complexity: O(log(m × n)) Big takeaway: Sometimes the problem isn’t 2D at all — it’s just perspective. Stacking binary search patterns now. 🚀 #100DaysOfCode #LeetCode #DSA #Algorithms #BinarySearch #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #ComputerScience #Consistency #Programmers #TechGrowth
Yogesh ..’s Post
More Relevant Posts
-
Today I solved the classic problem: Longest Substring Without Repeating Characters This problem teaches one of the most important techniques in DSA — the Sliding Window Algorithm. 🔹 Used HashMap for tracking character positions 🔹 Optimized solution to O(n) time complexity 🔹 Strengthened understanding of two-pointer technique #DSA #DataStructures #Algorithms #LeetCode #Java #ProblemSolving #CodingJourney #100DaysOfCode #SoftwareDeveloper #TechLearning #Consistency #CodingPractice #InterviewPreparation #SlidingWindow #GrowthMindset
To view or add a comment, sign in
-
Day 33/100 | #100DaysOfDSA 🌳💻 Today’s problem: Binary Tree Postorder Traversal Postorder follows a simple rule: Left → Right → Root Approach: • Use recursion • Traverse left subtree • Traverse right subtree • Add the root at the end This ensures children are processed before the parent. Time Complexity: O(n) Space Complexity: O(h) (recursion stack) Big takeaway: Tree traversals are just different visiting orders — mastering them builds strong tree intuition. Stacking tree patterns daily. 🚀 #100DaysOfCode #LeetCode #DSA #BinaryTree #Trees #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #Consistency #Programmers #TechGrowth
To view or add a comment, sign in
-
-
Another day another problem💪 In this problem, the array is sorted but rotated at an unknown pivot. Instead of using a linear search (O(n)), I applied a binary search strategy to maintain O(log n) time complexity. 💡 Key Learnings: Handling edge cases in rotated arrays Understanding how to calculate the real mid index after rotation Strengthening binary search fundamentals Consistent practice is helping me improve my problem-solving and DSA skills step by step. 💪 #LeetCode #DSA #BinarySearch #Java #Coding #ProblemSolving #SoftwareDeveloperJourney
To view or add a comment, sign in
-
-
Day 41 – Longest Consecutive Sequence Solved a problem to find the length of the longest sequence of consecutive numbers in an unsorted array while maintaining O(n) time complexity. Key Learnings: Using a HashSet to efficiently check the presence of elements Identifying the start of a sequence by checking if the previous number exists Expanding the sequence to count consecutive numbers without sorting the array Optimizing the approach to avoid nested loops #DSA #Java #HashSet #Algorithms #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
#Day67 of my second #100DaysOfCode Today’s problem pushed me to think carefully about comparisons and sorting logic. DSA • Solved Reverse Pairs (LeetCode 493) — count pairs (i, j) such that i < j and nums[i] > 2 * nums[j] • Brute force: check every pair using nested loops → O(n²) time • Optimal approach: Modified Merge Sort to count valid pairs during merge → O(2n log n) time, O(n) space • Key insight: count pairs across the left and right halves before merging. Another reminder of how divide-and-conquer + merge sort patterns appear in many hard problems. #DSA #Algorithms #LeetCode #MergeSort #Java #100DaysOfCode #WomenWhoCode #BuildInPublic #LearningInPublic
To view or add a comment, sign in
-
-
💡 Detecting Duplicates using Insertion Sort Logic (No Extra Space!) Instead of using HashSet or extra memory, I tried a different approach — modifying Insertion Sort. 👉 Idea: Assume the left part of the array is already sorted. When inserting the next element (key), we shift bigger elements right. During shifting: If we meet an element equal to the key → Duplicate found immediately If smaller → insert at correct position In simple words: Keep shifting while elements are bigger If equal → duplicate If smaller → insert 📊 Complexity: • Worst Case: O(n²) • Space: O(1) • Early exit if duplicate appears Nice reminder that sometimes classic sorting logic can double as a searching technique! #DSA #Java #Algorithms #ProblemSolving #CodingInterview
To view or add a comment, sign in
-
-
Day 37/100 🚀 | #100DaysOfDSA Solved Reverse String by Character Type – LC 3823 This problem required reversing characters in a string — but with a twist. Letters and special characters had to be reversed within their own groups while keeping their original positions relative to each other. Example idea: Letters reverse among letters, special characters reverse among specials. My Approach: • Converted the string to a character array for easier traversal. • Used two stacks — one for letters and one for special characters. • First pass: pushed characters into their respective stacks. • Second pass: rebuilt the string by popping from the correct stack depending on the character type. Time Complexity: O(n) Space Complexity: O(n) Key Learning: Breaking a problem into categories can simplify the logic significantly. Once characters were separated by type, reconstructing the result became straightforward. Small problems. Clear thinking. Consistent progress. 💪 #100DaysOfCode #LeetCode #DSA #Java #Strings #Stacks #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
Understanding Tree Structure Beyond Just Values Today I solved the Same Tree problem while practicing Binary Trees. While working on Same Tree, I realized something important: 👉 Two trees are not the same just because they contain the same values. 👉 Their structure must also be identical. 💡 Key Learnings: Tree comparison requires checking both node values and structure. Recursive DFS makes the solution clean and intuitive. Base cases (both null, one null, value mismatch) are critical. Logical clarity matters more than writing complex code. This problem strengthened my understanding of: ✔ Recursive thinking ✔ Base condition handling ✔ Structural comparison in trees ✔ Writing clean and interview-ready DFS code Every tree problem improves not just coding skills, but problem-solving mindset. #DSA #Java #BinaryTree #DFS #LeetCode #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
Day 17/100 | #100DaysOfDSA Today’s problem: Valid Anagram Two strings. Same letters. Same frequency. That’s it. Approach: • Use a frequency array (size 26) • Increment for first string • Decrement for second string • If all values → 0, it’s an anagram Time complexity: O(n) Big takeaway: When order doesn’t matter — count. Simple idea. Efficient solution. Clean execution. ⚡✨ #100DaysOfCode #LeetCode #DSA #Algorithms #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity #SoftwareEngineer #ComputerScience #Consistency #Programmers #TechGrowth
To view or add a comment, sign in
-
-
Day 17 of DSA practice 🚀 (Deep Dive into Binary Search) Today I solved Problem #4 – Median of Two Sorted Arrays — and it was a really insightful one. Instead of merging the two sorted arrays (which would take O(n + m) time), I learned a smarter approach to find the median without actually creating the combined array. Key takeaways: 1) Using binary search on partitions instead of values 2) Dividing the arrays in a way that left partition ≤ right partition 3) Achieving O(log(min(n, m))) time complexity Beyond the algorithm, I also learned something important about code design: The importance of separation of concerns. Breaking the logic into clear responsibilities made the solution more readable, easier to debug, and conceptually simpler — even for a complex problem. Today wasn’t just about solving a hard problem, it was about improving how I think and structure solutions 🔥 #DSA #LeetCode #BinarySearch #Algorithms #ProblemSolving #CleanCode #Java #LearningInPublic #100DaysOfCode
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