🚀 Day 11/100 — LeetCode Challenge Solved Capacity To Ship Packages Within D Days The problem is not about finding an element… It’s about finding the minimum capacity that satisfies a condition. 💡 Approach: The answer lies between: 👉 max(weights) and sum(weights) 1) Apply binary search on this range 2) For each capacity, simulate shipping: -Count how many days it takes -If days ≤ given → try smaller capacity -Else → increase capacity 👉 This is a mix of binary search + greedy validation 🧠 Time Complexity: O(n log n) 💾 Space Complexity: O(1) 💡 What I learned: Whenever the problem asks for minimum/maximum value under a constraint, there’s a high chance it can be solved using binary search on answer. This pattern is getting clearer now. #LeetCode #DSA #100DaysOfCode #Cpp #BinarySearch #Greedy #CodingJourney
LeetCode Challenge: Capacity To Ship Packages Within D Days
More Relevant Posts
-
🚀 Day 12/100 — LeetCode Challenge Solved Split Array Largest Sum At first, it looks like a DP problem, but there’s a smarter way. 💡 Key Idea: We need to minimize the maximum subarray sum. 👉 Instead of directly finding the answer, we binary search on the answer space. 1) Range: max(nums) → sum(nums) 2) For each mid (possible max sum): -Check how many subarrays are needed -If subarrays ≤ k → try smaller answer -Else → increase it 👉 Again, a combination of Binary Search + Greedy 🧠 Time Complexity: O(n log n) 💾 Space Complexity: O(1) 💡 What I’m realizing: Problems like: 1) Smallest Divisor 2) Ship Capacity 3) Split Array …are all variations of the same pattern. Once the pattern clicks, multiple problems become easier. #LeetCode #DSA #100DaysOfCode #Cpp #BinarySearch #Greedy #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 17/100 — LeetCode Challenge Solved Reverse Linked List At first, it feels tricky because we need to change the direction of links without losing the list. 💡 Approach (Iterative): 1) Use three pointers: prev, curr, next 2) Store the next node 3) Reverse the link (curr → prev) 4) Move all pointers forward 👉 Repeat until the list is fully reversed 💡 Key Insight: We’re not just moving through the list, we’re rebuilding it in reverse order. 🧠 Time Complexity: O(n) 💾 Space Complexity: O(1) 💡 What I learned: Linked List problems are less about logic, and more about careful pointer handling. One small mistake = broken list. #LeetCode #DSA #100DaysOfCode #Cpp #LinkedList #CodingJourney
To view or add a comment, sign in
-
-
Day 29 of Solve With Me : Today’s problem: Fizz Buzz (LeetCode 412) We are given an integer n. Our task is to return a list of strings from 1 to n with the following rules: What are the rules? If number is divisible by 3 → "Fizz" If number is divisible by 5 → "Buzz" If divisible by both 3 and 5 → "FizzBuzz" Otherwise → the number itself as a string Approach : Create an empty list Iterate from 1 to n For each number: Check i % 3 == 0 && i % 5 == 0 → add "FizzBuzz" Else if i % 3 == 0 → add "Fizz" Else if i % 5 == 0 → add "Buzz" Else → add number as string Return the list Why this works ? We check the most specific condition (divisible by both) first, so it doesn’t get overridden by individual checks. Example Input : n = 5 Output : ["1", "2", "Fizz", "4", "Buzz"] #leetcode #problemsolving #dsa #codingpractice #day29
To view or add a comment, sign in
-
-
🚀 Day 51 of my LeetCode Journey Solved: Roman to Integer At first glance, this problem looks simple — just map symbols to numbers. But the real catch is handling subtractive cases like IV (4), IX (9), etc. 💡 Key Learning: Instead of blindly adding values, you need to compare current and next characters: If current < next → subtract Else → add This small twist is what separates a correct solution from a wrong one. 📊 Result: ✅ Accepted ⏱️ Runtime: 6 ms 📌 Takeaway: Even “easy” problems test your attention to detail. Don’t underestimate them. Consistency > Motivation. See you on Day 52. #LeetCode #DSA #CodingJourney #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
🧠 Day 32/75: Solving for the "End" from the "Beginning" Linked Lists can be tricky because you can't access elements by index. So, how do you remove the Nth element from the back without knowing the total length? Today’s LeetCode session was a deep dive into Pointer Logic. By maintaining a specific distance between two pointers, I was able to identify and delete the target node in a single traversal. Current Progress: 📅 32 Days Consecutive 🎯 Focus: Advanced Linked List Patterns ⚡ Result: 100% Beats Runtime Another day, another problem solved. The second month is off to a strong start! 💻🔥 #Consistency #100DaysOfCode #DSA #CodingJourney #JavaDeveloper #TechGrowth #LeetCodeChallenge #LinkedInLearning
To view or add a comment, sign in
-
-
LeetCode Progress 48/50 — Guess Number Higher or Lower I worked on a fundamental problem focused on binary search and decision optimization 🧩 💡 The challenge was to guess a picked number by narrowing down the search space efficiently. 🧠 Approach: Used binary search strategy by repeatedly dividing the range into halves based on feedback (higher/lower), reducing the number of guesses required. ⏱ Time Complexity: O(log n) 💡 What I learned: This problem reinforced how binary search is not just for arrays, but also for optimizing decision-based problems by eliminating half the search space each step. 📈 Strengthening core binary search intuition and improving problem-solving efficiency. #LeetCode #DSA #BinarySearch #ProblemSolving #Cpp #CodingJourney #Consistency 🚀
To view or add a comment, sign in
-
-
Most people understand cycle detection… but get stuck when asked to find where the cycle starts. 🚀 Day 19/100 — LeetCode Challenge Solved Linked List Cycle II 💡 Step 1: Detect cycle -Use slow & fast pointers -If they meet → cycle exists 💡 Step 2: Find starting node -Move fast back to head -Move both one step at a time -Where they meet again → start of cycle 👉 This part is pure intuition + math 🧠 Time Complexity: O(n) 💾 Space Complexity: O(1) 💡 What I learned: Detecting a cycle is easy. Finding its starting point is where real understanding begins. This is one of those problems where you either memorize… or truly understand. Have you ever understood why this works? #LeetCode #DSA #100DaysOfCode #Cpp #LinkedList #TwoPointers #CodingJourney
To view or add a comment, sign in
-
-
Day 40 | LeetCode Learning Journal 🚀 Today I solved Validate Binary Search Tree (BST) using a range-based recursive approach. This problem helped me deeply understand how BST properties apply to the entire tree, not just immediate children! 🔑 Key Points: • Checked whether a binary tree is a valid BST. • Maintained a valid range (min, max) for each node. • Ensured every node follows BST rules globally. • Used recursion to traverse and validate nodes. 🌱 What I Learned: • Importance of passing constraints (min/max) in recursion. • Difference between local vs global validation in trees. • Strengthened understanding of Binary Search Tree properties. • Improved recursive thinking for tree problems. #LeetCode #100DaysOfCode #DSA #CodingJourney #Day40 🚀
To view or add a comment, sign in
-
-
LeetCode Progress 19/50 — Third Maximum Number I worked on a problem focused on array traversal and finding distinct elements 🧩 💡 The challenge was to find the third distinct maximum number in an array, and if it does not exist, return the maximum number. 🧠 Approach: Tracked the top three distinct maximum values while iterating through the array, ensuring duplicates were ignored. This avoided the need for extra sorting and kept the solution efficient. ⏱ Time Complexity: O(n) 💡 What I learned: This problem reinforced how maintaining a few variables smartly can replace the need for sorting and lead to optimized solutions. 📈 Improving efficiency in handling arrays and focusing on writing optimized logic. #LeetCode #DSA #ProblemSolving #Cpp #CodingJourney #Consistency 🚀
To view or add a comment, sign in
-
-
Day 22/128 of my LeetCode journey 🚀 Solved Longest Common Prefix today — a simple-looking problem that really highlights the importance of string manipulation and careful comparisons. 💡 Key takeaway: Instead of comparing every string fully, I learned how to progressively shrink a candidate prefix until it matches all strings. It’s a great example of optimizing by eliminating unnecessary checks early. 🔍 What I practiced: String traversal and comparison Iterative problem-solving (refining the prefix step by step) Writing clean and efficient logic Every problem might not be complex, but each one strengthens the fundamentals — and that’s what builds strong problem-solving skills. #LeetCode #DSA #CodingJourney #128DaysOfCode #SoftwareEngineering #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