🚀 Day 41 of #100DaysOfDSA (Java) Today I continued with Graphs (Part 2) and covered important concepts used in real interview problems. Topics covered: 🔹 Connected Components in Graphs 🔹 Cycle Detection in Undirected Graph (DFS) 🔹 Cycle Detection in Directed Graph (DFS) 🔹 Bipartite Graph 🔹 Topological Sorting (using DFS) Key takeaway: Graph problems are all about traversal + state tracking. Understanding how to use DFS with additional conditions (like parent tracking or recursion stack) is crucial for solving problems like cycle detection and topological sorting. Day 41 ✅ Strengthening concepts in one of the most important DSA topics. #DSA #Java #Graphs #DFS #TopologicalSort #ProblemSolving #100DaysOfCode #DeveloperJourney #LearningInPublic
Graphs and DFS in Java #100DaysOfDSA
More Relevant Posts
-
Day 61/100 | #100DaysOfDSA 🧩🚀 Today’s problem: Median of Two Sorted Arrays A classic hard problem with a clever binary search approach. Problem idea: Find the median of two sorted arrays without fully merging them. Key idea: Use binary search on the smaller array to partition both arrays. Why? • We want left half and right half to be balanced • All elements in left ≤ all elements in right How it works: • Pick a cut in array1 • Derive cut in array2 • Check partition validity using boundary elements If valid → we found the median If not → adjust the partition Time Complexity: O(log(min(m, n))) Space Complexity: O(1) Big takeaway: Binary search isn’t just for searching — it can be used to optimize partitions and positions. This one really builds intuition. 🔥 Day 61 done. #100DaysOfCode #LeetCode #DSA #Algorithms #BinarySearch #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity
To view or add a comment, sign in
-
-
Day 25/100: Finding the "Gap" 🎯 Today's challenge: Search Insert Position. We all know Binary Search finds an element in O(log n), but what if the element isn't there? I learned that by the end of the search, the `left` pointer doesn't just give up—it points exactly to where that missing number *should* be inserted to keep the array sorted. It’s a powerful way to handle dynamic data without breaking the order. Quarter of the way through the challenge! 🚀 #100DaysOfCode #Java #DSA #BinarySearch #ProblemSolving #Unit3 #Day25 #LearnInPublic
To view or add a comment, sign in
-
-
Day 74 - Univalued Binary Tree Checking whether all nodes in a binary tree share the same value using recursion. Approach: • Store root value • Traverse the tree recursively • Compare each node with root value • Return false if any mismatch is found Key Insight: Recursion simplifies tree traversal and validation Time Complexity: O(n) #Day74 #LeetCode #Java #CodingPractice #TechJourney #DSA #BinaryTree
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟓𝟔 – 𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 | 𝐀𝐫𝐫𝐚𝐲𝐬 🚀 Today’s problem focused on finding a peak element using binary search. 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐨𝐥𝐯𝐞𝐝 • Find Peak Element 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 • Used binary search instead of linear scan • Compared the middle element with its next element Logic: • If nums[mid] > nums[mid + 1] → peak lies on the left side (including mid) • Else → peak lies on the right side • Continued until left == right 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬 • Binary search can be applied on patterns, not just sorted arrays • A peak always exists due to problem constraints • Comparing adjacent elements helps determine direction • Reducing the search space is the key idea 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲 • Time: O(log n) • Space: O(1) 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲 Binary search is not about sorted arrays — it’s about eliminating half of the search space using logic. 56 days consistent 🚀 On to Day 57. #DSA #Arrays #BinarySearch #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
To view or add a comment, sign in
-
-
Day 68 of My DSA Journey Today’s problem: Symmetric Tree 🌳 Problem Statement Given a binary tree, check whether it is a mirror of itself (symmetric around its center). Key Insight A tree is symmetric if: Left subtree is a mirror of the right subtree Compare nodes in a cross manner: Left → Left with Right → Right Left → Right with Right → Left 🧠 Approach Use recursion to compare two nodes at a time Base cases: If both nodes are null → symmetric If one is null → not symmetric Check: Values are equal Outer and inner pairs match ⚡ Complexity Time: O(n) Space: O(h) (recursion stack) ✨ What I Learned This problem improved my understanding of recursion and how to think in terms of mirror structures instead of normal traversal. Consistency is the key 🔑 — one problem at a time! #DSA #Java #BinaryTree #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 60 – Search a 2D Matrix Solved a problem to efficiently search for a target in a sorted matrix using binary search. Key Learnings: Learned to treat a 2D matrix as a flattened sorted array Understood index mapping from 1D to 2D (row = mid / cols, col = mid % cols) Strengthened problem-solving skills in optimized searching techniques #DSA #Java #BinarySearch #Matrix #ProblemSolving #CodingPractice
To view or add a comment, sign in
-
-
Day 32/50 🚀 — Search Insert Position (Binary Search) Today’s problem reinforced one of the most important concepts in DSA — Binary Search 🔍 🔹 Applied efficient search in a sorted array 🔹 Focused on boundary conditions 🔹 Learned how to return the correct insert position when target isn’t found Key insight: Binary search isn’t just about finding an element — it’s about narrowing down the answer space intelligently. 💡 Returning left at the end ensures we get the exact position where the target should be inserted. Performance highlights: ⚡ Runtime: 0 ms (100%) 📦 Memory: Optimized #Day32 #LeetCode #BinarySearch #DSA #Java #CodingJourney #50DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
Day 60/100 | #100DaysOfDSA 🧩🚀 Today’s problem: Minimized Maximum of Products Distributed to Any Store Interesting use of binary search on answer. Problem idea: We need to distribute products to stores such that the maximum products any store gets is minimized. Key idea: Apply binary search on the answer (max products per store). Why? • If a maximum limit works → try smaller • If it doesn’t → increase the limit For each candidate value: • Check how many stores are required • If stores ≤ given n → valid distribution This way we efficiently find the minimum possible maximum. Time Complexity: O(n log m) Space Complexity: O(1) Big takeaway: Whenever you need to minimize the maximum (or maximize the minimum) → think Binary Search on Answer. These patterns are becoming clearer day by day. 🔥 Day 60 done. #100DaysOfCode #LeetCode #DSA #Algorithms #BinarySearch #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity
To view or add a comment, sign in
-
-
🚀 Day 83 of #100DaysOfCode Solved 3217. Delete Nodes from Linked List Present in Array on LeetCode 🔗 🧠 Key Insight: We need to remove all nodes from the linked list whose values exist in a given array 👉 Fast lookup is required → use a HashSet ⚙️ Approach (HashSet + Traversal): 1️⃣ Store all array elements in a HashSet 🔹 set.add(nums[i]) 2️⃣ Use a dummy node before head 🔹 Helps handle deletion at head easily 3️⃣ Traverse the list: 🔹 If node.next.val exists in set → delete it 👉 node.next = node.next.next 🔹 Else → move forward 4️⃣ Return dummy.next ⏱️ Time Complexity: O(n + m) 📦 Space Complexity: O(m) #100DaysOfCode #LeetCode #DSA #LinkedList #HashSet #TwoPointers #Java #InterviewPrep #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 44/60 – DSA Challenge Today’s problem was about finding the minimum element in a rotated sorted array using Binary Search 🔍 🔍 Problem Solved: Given a sorted array that has been rotated, find the minimum element efficiently. 🧠 Approach I Used: Instead of scanning the array linearly, I used Binary Search: Compare the middle element with the last element If the middle is greater → minimum lies on the right side Otherwise → minimum lies on the left side Keep shrinking the search space until the answer is found ⚡ Key Insight: The comparison with the last element helps determine which part of the array is sorted and where the minimum lies. 📈 Complexity: Time: O(log n) Space: O(1) 🎯 What I Learned: Binary Search can be adapted to solve rotated array problems Understanding array structure is more important than memorizing logic Edge cases and boundary handling are crucial for correctness Improving step by step, one problem at a time 🔥 #Day44 #DSAChallenge #BinarySearch #Java #ProblemSolving #Consistency
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