🚀 Day 81 / 100 – LeetCode Daily Challenge 📌 Problem: Minimum Partitions to Decompose a Number (1689) 🧠 Concept: Greedy | String Manipulation Today’s problem was deceptively simple but conceptually rich — finding the minimum number of deci-binary numbers needed to sum up to a given string n. The key insight? 🔍 The answer is simply the maximum digit in the string! Why? Because in any addition of deci-binary numbers (each made of only 0s and 1s), the largest digit in the target number dictates how many numbers are needed in the worst-case scenario. So if the number is "82734", we need at least 8 numbers (one for each unit at the position of '8'). ✅ One pass. One max check. Clean and greedy. 📊 Runtime: 6 ms | Beats 75.56% 💾 Memory: 47.43 MB ✨ Key takeaway: Sometimes the most efficient solution is hiding in plain sight — just read the problem carefully and think about the underlying constraints. #LeetCode #CodingJourney #100DaysOfCode #Day81 #GreedyAlgorithm #Java #ProblemSolving #TechCommunity #DevLife #CodeNewbie
Minimum Partitions to Decompose a Number with Greedy Algorithm
More Relevant Posts
-
🚀 Day 21 of my #100DaysOfCode Journey Today, I solved the LeetCode question Contains Duplicate II. The task is to check if there are two equal elements in the array such that their index difference is at most k. ✅ Steps: First, iterate through each element in the array For every element, check only the next k elements Compare values within this limited range If a match is found → return true 💻 My Approach: I used a sliding window + brute force approach (without using HashMap/HashSet). Instead of checking the whole array, I optimized it by limiting the inner loop to k distance only. 🌟 Learning Takeaways: Optimizing brute force can avoid TLE Understanding constraints (like k distance) helps reduce complexity Multiple approaches exist — choosing based on space/time is key #DSA #Java #LeetCode #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Day 69 — LeetCode Practice 🚀 Today’s focus was on string manipulation and careful indexing. ✅ Problem solved today: 🔹 Find Common Characters 💡 Key learnings from today: • Understood how to find common characters across multiple strings • Learned the importance of character frequency counting • Practiced handling nested loops efficiently • Realized how small mistakes in indexing can affect the entire logic • Improved attention to detail while working with strings Initially, I made a mistake by using the wrong variable inside charAt(). This caused incorrect indexing, which can either lead to wrong output or even StringIndexOutOfBoundsException. After fixing it, the logic worked perfectly by correctly comparing characters and tracking their minimum frequency across all words. This problem reinforced an important lesson: Sometimes errors are not in logic — but in small details like indexing and variable usage. Accuracy matters as much as logic. Step by step, getting better 💪 On to Day 70 🚀 #Day69 #DSA #LeetCode #ProblemSolving #Java #CodingJourney #Consistency #FutureEngineer
To view or add a comment, sign in
-
-
Just cracked LeetCode #9 – Palindrome Number. Sounds simple, but the follow-up challenge of solving it without converting to a string makes you really think about the math behind it. 🚀 The approach was straightforward — reverse the number mathematically (no string conversion!) and compare it with the original. Negative numbers and trailing zeros are the edge cases that catch you off guard if you're not careful. 🧑💻 Beats 79.66% in runtime and 95.20% in memory. Not perfect, but I'll take it. One problem at a time. That's the game. 💪 #LeetCode #Java #DSA #CodingJourney #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 531 of #750DaysOfCode 🚀 💻 LeetCode 1415 — The K-th Lexicographical Happy String of Length n Today’s problem was a great practice of Backtracking + Recursion + Lexicographical order generation. We are given a length n and a number k, and we need to find the k-th happy string in sorted order. 🔹 A happy string means: Only contains characters → a, b, c No two adjacent characters are same Example: Valid → "abc", "acb", "bab" Invalid → "aa", "abb", "bcc" The challenge was to generate all valid strings in lexicographical order and return the k-th one. 💡 Approach Used: Backtracking (DFS) Try characters in order → a, b, c Skip same adjacent character Stop early when k-th string found This problem improved my understanding of: ✔ Recursion ✔ Backtracking ✔ String generation ✔ Lexicographical traversal ✔ Early stopping optimization Consistency is the key — one problem every day, no excuses. 🔥 #750DaysOfCode #Day531 #LeetCode #Java #Backtracking #Recursion #DSA #CodingJourney #SoftwareEngineer #PlacementPreparation
To view or add a comment, sign in
-
-
🚀 Day 50 / 100 – LeetCode Challenge Solved 108. Convert Sorted Array to Binary Search Tree 🌳 Today’s problem was all about building a height-balanced BST from a sorted array using a smart approach. 💡 Key Insight: Instead of inserting elements one by one, pick the middle element as root. This ensures the tree remains balanced. 🔁 Approach: Choose middle element → Root Left half → Left subtree Right half → Right subtree Apply recursively (Divide & Conquer) 🧠 Why it works? Because the array is sorted, the middle element naturally divides values into left < root < right. ⚡ Complexity: Time: O(n) Space: O(log n) ✅ Result: Accepted | 0 ms runtime | 100% performance Consistency is the real win here 💪 Halfway through the challenge! #Day50 #LeetCode #100DaysOfCode #Java #CodingJourney #DSA #BinaryTree #TechGrowth
To view or add a comment, sign in
-
-
🚀 Day 28/50 — LeetCode #1768: Merge Strings Alternately Another day, another clean problem solved ✅ 💡 Approach: Used a single pointer to traverse both strings and alternately append characters. If one string is longer, just continue with the remaining characters. 🔧 Highlights: Used StringBuilder for efficient string manipulation Simple loop with boundary checks No extra complexity — just clean logic ⚡ Complexity: Time: O(n + m) Space: O(n + m) 📌 Takeaway: Problems like this remind me that clarity beats over-engineering. The simplest approach is often the best one. Consistency is the real win here — showing up every day and improving bit by bit. #Day28 #LeetCode #Java #DSA #CodingJourney #50DaysOfCode
To view or add a comment, sign in
-
-
Day 20/100 🚀 | LeetCode Grind Cracked “Guess Number Higher or Lower” using Binary Search 🎯 Optimized the approach by narrowing down the search space efficiently with each guess — classic divide & conquer in action. 💡 Key Takeaway: When the search space is sorted and bounded, Binary Search is your best friend. ⚡ Runtime: 0 ms (Beats 100%) 📊 Efficient and clean implementation Consistency > Intensity. Showing up every day 💪 #Day20 #100DaysOfCode #LeetCode #DSA #BinarySearch #CodingJourney #Java #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Day 8 of #100DaysOfCode Solved: Maximum Product of Two Elements in an Array 💻 Today’s problem was all about optimizing logic and thinking smart instead of brute force. Instead of checking every pair, I focused on finding the two largest elements efficiently and used them to compute the result in a single pass 🔥 ✅ Time Complexity: O(n) ✅ Space Complexity: O(1) Small problems like these really sharpen problem-solving skills and reinforce the importance of clean, efficient code. Consistency is key — showing up every day, learning something new, and getting 1% better 💯 #DSA #Java #CodingJourney #LeetCode #ProblemSolving #Consistency #Day8#DSAwithEdSlash
To view or add a comment, sign in
-
-
Day 75/200 – LeetCode Challenge Given a string of digits, the task is to generate all possible valid IP addresses by inserting dots. Sounds simple, but the challenge lies in handling. Try placing dots at every possible position. Validate each segment before moving forward. Prune invalid paths early to save time. Backtracking becomes powerful when combined with early pruning. Instead of exploring all possibilities, we cut off invalid paths immediately, making the solution efficient. Problems like this strengthen recursion + validation thinking. The more you practice, the better you get at spotting patterns. #Day75 #LeetCode #CodingChallenge #Java #200DaysOfCode
To view or add a comment, sign in
-
-
Day 31/50 🚀 — Reverse Vowels of a String (LeetCode 345) Today’s problem was a great reminder that sometimes the simplest approaches are the most efficient. 🔹 Used the two-pointer technique 🔹 Focused on in-place swapping 🔹 Optimized for both time (O(n)) and space (O(1)) Key takeaway: Instead of overthinking, break the problem into smaller checks—identify vowels, move pointers smartly, and swap only when needed. Clean and efficient 💡 Happy to see this solution performing well: ⚡ Runtime: 2 ms (faster than 99%+) 📦 Space: Decent optimization #Day31 #LeetCode #DSA #Java #CodingJourney #50DaysOfCode #ProblemSolving #SoftwareEngineering
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