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
Minimizing Max Products Distributed with Binary Search
More Relevant Posts
-
Day 62/100 | #100DaysOfDSA 🧩🚀 Today’s problem: Combination Sum Classic backtracking problem. Problem idea: Find all unique combinations where numbers sum up to a target. Each number can be used unlimited times. Key idea: Use backtracking (choose → explore → backtrack). Why? • We need to explore all possible combinations • Stop when sum exceeds target • Add result when sum == target How it works: • Pick a number • Stay on same index (reuse allowed) • Move forward when skipping • Backtrack to try other paths Time Complexity: Exponential (depends on combinations) Space Complexity: O(target) recursion depth Big takeaway: Backtracking is all about exploring choices and undoing them efficiently. This pattern is super important for recursion problems. 🔥 Day 62 done. #100DaysOfCode #LeetCode #DSA #Algorithms #Backtracking #Java #CodingJourney #ProblemSolving #InterviewPrep #TechCommunity
To view or add a comment, sign in
-
-
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 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
-
-
📘 DSA Journey — Day 30 Today’s focus: HashMap for frequency counting. Problem solved: • Number of Good Pairs (LeetCode 1512) Concepts used: • HashMap • Frequency counting • Incremental counting technique Key takeaway: The goal is to count pairs (i, j) such that nums[i] == nums[j] and i < j. Instead of checking all pairs (which would take O(n²)), we use a HashMap to track frequencies. As we iterate through the array: • For each number, we check how many times it has already appeared • That count directly contributes to the number of valid pairs • Then we update its frequency in the map This allows counting pairs in a single pass with O(n) time complexity. Continuing to strengthen fundamentals and consistency in problem solving. #DSA #Java #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
🚀 #100DaysOfCode | Day 47 🔍 Solved: Find Minimum in Rotated Sorted Array Today I explored another interesting variation of Binary Search. Instead of searching for a target, the goal was to find the minimum element in a rotated sorted array. 💡 Key Insight: By comparing the middle element with the last element, we can determine which half contains the minimum value. Approach: ✔ Used Binary Search to achieve O(log n) time complexity ✔ Compared mid with end to identify the unsorted portion ✔ Narrowed down the search space efficiently What I Learned: This problem helped me understand how binary search can be applied beyond simple searching—especially in rotated and partially sorted arrays. #Java #DSA #LeetCode #BinarySearch #CodingJourney #ProblemSolving #TechSkills
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
-
-
📘 DSA Journey — Day 27 Today’s focus: Binary Search on modified arrays. Problem solved: • Search in Rotated Sorted Array (LeetCode 33) Concepts used: • Binary Search • Identifying sorted halves • Conditional search space reduction Key takeaway: This problem extends binary search to a rotated sorted array, where the array is not fully sorted but divided into two sorted parts. At each step, we: • Find the mid element • Check which half (left or right) is sorted • Decide whether the target lies in the sorted half • Eliminate the other half This allows us to still achieve O(log n) time complexity. Continuing to strengthen fundamentals and problem-solving consistency. #DSA #Java #LeetCode #CodingJourney
To view or add a comment, sign in
-
-
🚀 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
To view or add a comment, sign in
-
-
Day 70 of My DSA Journey Problem: Linked List Cycle (LeetCode 141) Today’s problem was all about detecting whether a linked list contains a cycle — a classic and very important concept in data structures. Key Idea: Floyd’s Cycle Detection Algorithm (Tortoise & Hare) Instead of using extra memory, we use two pointers: • Slow pointer → moves 1 step • Fast pointer → moves 2 steps If there’s a cycle, these two pointers will eventually meet. If not, the fast pointer will reach the end (null). Insight: This approach is efficient because it avoids using extra space like a HashSet and still guarantees detection in linear time. Complexity: • Time: O(n) • Space: O(1) What I learned: Sometimes, the smartest solutions don’t require extra space — just a clever observation and pointer manipulation! Consistency > Perfection 💯 On to Day 71 🚀 #DSA #100DaysOfCode #Java #CodingJourney #ProblemSolving #LinkedList
To view or add a comment, sign in
-
-
💻 Day 80 – DSA Practice (Binary Trees) Today’s challenge: 👉 Find all root-to-leaf paths where the sum equals a given target. 🔹 Approach: Use Depth-First Search (DFS) Track the current path and remaining sum When reaching a leaf node, check if the sum matches 💡 Key Concepts: Recursion + Backtracking Tree traversal (DFS) Efficient sum handling ⚡ Insight: Reducing the target sum at each step makes the solution cleaner and avoids recalculating sums. #DSA #BinaryTree #Java #CodingJourney #100DaysOfCode #ProblemSolving
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