Day: 27/365 Problem: Divide an Array Into Subarrays With Minimum Cost II Hard Key takeaways/Learnings from this problem: 1. This one teaches how sliding window + data structures (like heaps or multisets) can turn a brute-force idea into something efficient. 2. Big takeaway: when constraints jump, the solution usually evolves from simple greedy to maintaining the right state dynamically. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
Divide Array into Subarrays with Min Cost: Sliding Window and Heaps
More Relevant Posts
-
Starting sorting algorithms made me slow down more than expected. Even with simple logic like Bubble Sort, tracking swaps, passes, and early stopping conditions forces you to think more clearly about how data actually moves. This phase is less about speed and more about precision. Foundations are being strengthened again. . . . . #DSA #Java #SortingAlgorithms #LearningInPublic #InternshipPreparation
To view or add a comment, sign in
-
🌱 Day 26 of #100DaysOfCode 🚀 📍 Day 26 Progress Started with the core concept of two pointers and how it helps in reducing time complexity for sorted data structures. ✅Worked on problems based on: 📌Prefix Sum 📌Finding pair sum equal to a target in two sorted arrays . Prefix Sum still needs more practice to gain stronger clarity and confidence, especially while handling edge cases. Building pattern recognition step by step 💙 #100DaysOfCode #DSA #TwoPointers #PrefixSum #Java #RevisionMode #LearningInPublic #Consistency
To view or add a comment, sign in
-
Day: 36/365 📌 LeetCode POTD: Longest Balanced Subarray II Hard Key takeaways/Learnings from this problem: 1. This one shows how segment trees help maintain balance info over ranges without recomputing everything again and again. 2. Big takeaway: when constraints grow, upgrading from prefix tricks to a range query data structure makes all the difference. #POTD #365DaysOfCode #DSA #Java #ProblemSolving #LearningInPublic #Consistency 🥷
To view or add a comment, sign in
-
🚀 Day 70 of #100DaysOfLeetCode Problem: 4Sum Difficulty: Medium Key Concept Learned: Sorting + Two Pointers + Duplicate Handling Today’s challenge was about finding all unique quadruplets in an array whose sum equals a given target. The optimized approach involved sorting the array, fixing two indices, and then using the two-pointer technique to efficiently search for valid combinations. Key takeaways: Sorting enables efficient pointer movement and duplicate detection Skipping duplicates at every level (i, j, left, right) is crucial to ensure uniqueness Two-pointer technique reduces the brute force complexity significantly Careful pointer handling avoids repeated results and improves performance A great problem for strengthening array manipulation, pointer logic, and edge-case handling. On to Day 71! 💪🔥 #LeetCode #DSA #Java #TwoPointers #Arrays #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 3 of Daily DSA 🚀 Solved LeetCode 1: Two Sum Approach: Used a HashMap to store numbers with their indices. For each element, checked if the complement (target - current) already exists. Complexity: • Time: O(n) • Space: O(n) Performance: Runtime: 2 ms (Beats 99.15%) Memory: 47.34 MB Focusing on writing clean and efficient solutions before over-optimizing. Consistency > Intensity 💯 #DSA #LeetCode #Java #ProblemSolving #Consistency
To view or add a comment, sign in
-
-
3Sum Problem: Recently solved the classic 3Sum problem by implementing it in three progressively optimized ways: 🔹 Brute Force – Checked all triplets (O(n³)) 🔹 Better Approach (Hashing) – Reduced one loop using a set (O(n²)) 🔹 Optimal Approach (Sorting + Two Pointers) – Efficient duplicate handling with O(n²) time and O(1) extra space Key takeaways: ✔️ Writing the brute-force solution first builds clarity ✔️ Sorting often unlocks powerful optimizations ✔️ Two-pointer technique is essential for array problems ✔️ Handling edge cases and duplicates carefully matters This exercise reinforced how structured thinking leads to better optimization — step by step. #DSA #Java #ProblemSolving #CodingPractice #LeetCode #SoftwareEngineering
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟐𝟓 – 𝐃𝐒𝐀 𝐉𝐨𝐮𝐫𝐧𝐞𝐲 | 𝐀𝐫𝐫𝐚𝐲𝐬 🚀 Today’s problem focused on sorting an array containing only three distinct values using an efficient counting approach. 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐒𝐨𝐥𝐯𝐞𝐝 • Sort Colors 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 𝟏 – 𝐂𝐨𝐮𝐧𝐭𝐢𝐧𝐠 𝐀𝐫𝐫𝐚𝐲 • Created a count array of size 3 • Counted occurrences of 0, 1, and 2 • Overwrote the original array using the frequency values • Simple and easy to implement 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠𝐬 • When value range is small, counting is powerful • Rewriting the array can be simpler than swapping • Constraints often guide the optimal approach • Clear thinking avoids overcomplication 𝐂𝐨𝐦𝐩𝐥𝐞𝐱𝐢𝐭𝐲 • Time: O(n) • Space: O(1) (since count array size is constant) 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲 Not every sorting problem needs full sorting logic — sometimes counting is enough. 25 days consistent. On to Day 26 🚀 #DSA #Arrays #Sorting #LeetCode #Java #ProblemSolving #DailyCoding #LearningInPublic #SoftwareDeveloper
To view or add a comment, sign in
-
-
🌳 Day 59/100: Preorder Traversal - Root, Left, Right Day 59. Learning tree traversals. Preorder: Visit root first, then explore. 🎯 📌 Problem: Return preorder traversal of binary tree. 🎯 Recursion: Base case: If node is null, return. Recursive case: Add value, go left, go right. Simple and clean. 📊 Complexity: O(n) time, O(h) space (recursion stack) 🌱 Tree Traversals: Preorder: Root → Left → Right Inorder: Left → Root → Right Postorder: Left → Right → Root Day 59. Traversal patterns building. 🌳 #100DaysOfCode #DSA #LeetCode #Day59 #Java #PreorderTraversal #BinaryTree #TreeTraversal
To view or add a comment, sign in
-
-
𝗗𝗮𝘆 𝟭𝟭/𝟮𝟬 — 𝗟𝗲𝗲𝘁𝗖𝗼𝗱𝗲 𝗖𝗵𝗮𝗹𝗹𝗲𝗻𝗴𝗲 Solved Reverse Integer using Mathematical Digit Extraction. ➤ Approach (O(log₁₀n), O(1) space): • Extract last digit using x % 10 • Remove last digit using x / 10 • Build reversed number using rev = rev * 10 + rem • Before updating, check for overflow using Integer.MAX_VALUE and Integer.MIN_VALUE ➤ Key Insight: The tricky part isn’t reversing — it’s handling overflow without using 64-bit integers. So before multiplying by 10, we ensure the result stays within 32-bit range. #LeetCode #Java #DSA #MathLogic #ProblemSolving #20DaysChallenge #Consistency
To view or add a comment, sign in
-
-
Merge Sorted Array (LeetCode : 88) 💻✨ In this problem, we are given two sorted arrays. The task is to create a final sorted array inside nums1 without using extra space. I used Two Pointer Technique here 👇 🔹 i → last valid index of nums1 🔹 j → last index of nums2 🔹 k → last index of nums1 (m + n - 1) We compare from the back because if we compare from the front, the data would be overwritten. 👉 If nums1[i] > nums2[j], then we put the larger value at the back. 👉 Otherwise, we put nums2[j]. 👉 Once any one of the arrays is finished, we copy the remaining elements. Time Complexity of this approach: O(m + n) Space Complexity: O(1) (In-place solution) 🚀 This problem reminded me again — If you think in the right direction, the solution becomes much easier. #LeetCode #androidDeveloper#problemslover#dsapattern#twopointer#dailyChallenge #DSA #Java #TwoPointerTechnique #ProblemSolving #CodingJourney #SoftwareDevelopment #InPlaceAlgorithm #DataStructures #AlgorithmThinking
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