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
Yogesh ..’s Post
More Relevant Posts
-
🚀 Day 49 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Set Mismatch Problem Insight: Given an array containing numbers from 1 to n, one number is duplicated and one number is missing. The goal is to find both of them. Approach: • Used a frequency array to count occurrences of each number • Traversed the input array and updated frequency • Iterated from 1 to n: – If frequency is 2 → duplicate element – If frequency is 0 → missing element • Returned both values as the final result Time Complexity: O(n) Space Complexity: O(n) Key Learnings: • Frequency array is a simple and powerful technique for counting problems • Helps quickly identify missing and repeating elements • Clean and easy-to-understand approach for beginners Takeaway: Sometimes the simplest approach is the most effective. Mastering basic patterns like counting can solve many problems efficiently! #DSA #Java #LeetCode #100DaysOfCode #CodingJourney
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
-
-
60-Day LeetCode Challenge – Day 43 Solved Check If Two String Arrays are Equivalent on LeetCode. 📌 Approach: Concatenated both string arrays into two strings and compared them using .equals(). 🧠 Learning: Reinforced how string building and comparison works, especially when data is split across arrays. ⚡ Complexity: • Time Complexity: O(n + m) • Space Complexity: O(n + m) Simple logic, but a clean reminder that breaking a problem down makes it easier to solve. #LeetCode #DSA #Java #Strings #Consistency #ProblemSolving #LeetCode60
To view or add a comment, sign in
-
-
🚀 Day 38 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Maximum Product of Two Elements in an Array. Problem Insight: Given an integer array, the goal is to find two elements such that: (nums[i] - 1) * (nums[j] - 1) is maximized Approach: • First, sort the array using Arrays.sort() • Use two nested loops to check all possible pairs • For each pair, calculate → (nums[i] - 1) * (nums[j] - 1) • Keep track of the maximum product Time Complexity: • O(n²) — due to nested loops Space Complexity: • O(1) — no extra space used Key Learnings: • Understanding operator precedence is very important in expressions • Sorting helps in simplifying many problems • Even simple problems can have optimized solutions beyond brute force Takeaway: Brute force helps in understanding the problem deeply, but optimization (like using the two largest elements directly) makes the solution efficient 🚀 #DSA #Java #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #Arrays
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
-
-
#Day53 of #100DaysDSAChallenge 🚀 Solved #LeetCode328: Odd Even Linked List The problem asks us to rearrange the nodes of a singly linked list such that all odd indexed nodes come first, followed by even indexed nodes, while preserving their relative order. 🔹 Approach: Brute Force Approach First traverse the linked list and store odd and even indexed values separately using an ArrayList. Then rewrite these values back into the linked list in required order. Time Complexity: O(n) Space Complexity: O(n) 🔹 Optimal Approach (Two Pointer Technique) Use two pointers: odd and even. Keep track of the head of even list (evenHead). Traverse the list and rearrange the next pointers such that: odd nodes are linked together even nodes are linked together Finally, connect the odd list with evenHead. Time Complexity: O(n) Space Complexity: O(1) 💡 Key Learning Instead of modifying values, focus on re-linking nodes for better space optimization. 🧠 Example Input: 1 → 2 → 3 → 4 → 5 Output: 1 → 3 → 5 → 2 → 4 Github repo: https://lnkd.in/g_rSFCh8 #100DaysOfDSA #DSA #LeetCode #Java #Algorithms #DataStructures #KunalKushwaha #Striver #GeeksForGeeks #ProblemSolving #CodingJourney #LearningInPublic #InterviewPrep #PlacementPreparation 🚀
To view or add a comment, sign in
-
-
🚀 Day 60/100 📌 Problem: String to Integer Given a string, convert it into a 32-bit signed integer while: • Ignoring leading whitespaces • Handling '+' and '-' signs • Reading digits until a non-digit appears • Returning INT_MAX or INT_MIN in case of overflow 💡 What I Learned: • Importance of handling edge cases • How to safely manage overflow • Writing clean and efficient parsing logic ⚡ Result: Runtime 1 ms (Beats 100%) Consistency + Practice = Improvement 📈 #Day60 #Java #DSA #LeetCode #CodingJourney #ProblemSolving #100DaysOfCode #LearnToCode
To view or add a comment, sign in
-
-
🚀 Day 39 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Concatenation of Array Problem Insight: Given an integer array nums, the goal is to create a new array by concatenating the array with itself. Approach: • Created a new array of size 2 * nums.length • Used a single loop to iterate through the array • Stored elements at two positions: - result[i] = nums[i] - result[i + nums.length] = nums[i] • This avoids using extra loops and keeps the solution efficient Time Complexity: • O(n) — only one traversal required Space Complexity: • O(n) — new array is created Key Learnings: • Efficient index handling can simplify problems • Avoid unnecessary loops for better performance • Strong fundamentals make simple problems powerful Takeaway: Smart thinking beats brute force — even simple problems can be solved in an optimal and elegant way . #DSA #Java #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving #Arrays
To view or add a comment, sign in
-
-
🚀 Day 43 of my #100DaysOfCode Journey Today, I solved the LeetCode problem: Sum of Unique Elements Problem Insight: Find elements in an array that appear exactly once and calculate their total sum. Approach: • Used a frequency array to count occurrences of each number • Traversed the array to build frequency • Added only those elements to sum whose frequency is exactly 1 Time Complexity: • O(n) Space Complexity: • O(1) (fixed size array used for constraints) Key Learnings: • Frequency array is faster than HashMap when range is fixed • Two-pass approach makes logic clear and simple • Always check constraints before choosing data structure Takeaway: Right data structure makes the solution simple and efficient 🚀 #DSA #Java #LeetCode #100DaysOfCode #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
Today I solved Two Sum (LeetCode #1 - Easy) 💡 🔍 Problem: Find two indices such that their values add up to the target. 🧠 Approach I used: HashMap Instead of checking every pair (O(n²)), I used a HashMap to optimize the solution. 👉 Steps: Calculate complement = target - current element Check if complement exists in the map If yes → return indices ✅ If no → store the element in the map ⚡ Time Complexity: O(n) ⚡ Space Complexity: O(n) 💡 This problem helped me understand how using extra space can reduce time complexity. 📌 Key Learning: “Optimize brute force by using HashMap for faster lookups.” #DSA #Java #LeetCode #CodingJourney #ProblemSolving #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