Skip to content
Y
yTube.SITE v8.0.4
media / worlds / tools / internet oddities
YouTube / video information

LeetCode 1689 | Partitioning Into Minimum Number Of Deci-Binary Numbers | Java | CodeByTushu

Video information, playback and saved actions.

LeetCode 1689 | Partitioning Into Minimum Number Of Deci-Binary Numbers | Java | CodeByTushu

Description: πŸš€ Welcome Back to CodeByTushu!

In today’s video, we solve LeetCode 1689 β€” Partitioning Into Minimum Number Of Deci-Binary Numbers using Greedy and Digit Optimization in Java.

A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. Given a string n representing a positive decimal integer, our goal is to find the minimum number of positive deci-binary numbers needed to sum up to n. Because deci-binary numbers can only contribute 0 or 1 at each column position and carries cannot reduce the maximum digit demand across columns, the minimum count required is strictly bounded by the maximum digit present in n.

Our implementation performs a single linear scan across the string n to determine the maximum digit character. We also incorporate an early exit optimization: if the digit 9 is encountered at any point, the function terminates immediately and returns 9, since no decimal digit can ever exceed 9. This delivers an optimal O(n) runtime and O(1) auxiliary space complexity.

πŸ”₯ Problem Highlights

βœ… Character digit parsing and running maximum tracking
βœ… Column-wise additive lower bound analysis with zero carries
βœ… Constructive proof showing sufficiency of max digit deci-binary numbers
βœ… Early-exit optimization upon encountering the maximum possible digit 9
βœ… In-place linear scan with zero heap memory allocation
βœ… Optimal O(n) time and O(1) auxiliary space complexity

⏱️ TIMESTAMPS

00:00 Intro & March 2026 Daily Challenge Kickoff
01:21 Problem Understanding & Deci-Binary Definition
02:45 Key Observation: Peak Column Value & Sufficiency
04:13 Greedy Maximum Digit Strategy (4 Steps)
05:26 Clean Java Solution Walkthrough Line by Line
06:34 Test Cases Walkthrough & Step-by-Step Simulation
07:57 Time Complexity Analysis (O(N) Time - 1 ms)
08:53 Space Complexity Analysis (O(1) Space)
09:36 Outro & Resources

πŸ“‚ Problem Folder & Detailed Documentation:
https://github.com/CodeByTushu/CodeByTushu-LeetCode-Solutions/tree/main/solutions/March/1-March/1689-Partitioning-Into-Minimum-Number-Of-Deci-Binary-Numbers

β˜• Java Solution:
https://github.com/CodeByTushu/CodeByTushu-LeetCode-Solutions/blob/main/solutions/March/1-March/1689-Partitioning-Into-Minimum-Number-Of-Deci-Binary-Numbers/Solution.java

🐍 Python Solution:
https://github.com/CodeByTushu/CodeByTushu-LeetCode-Solutions/blob/main/solutions/March/1-March/1689-Partitioning-Into-Minimum-Number-Of-Deci-Binary-Numbers/solution.py

⚑ C++ Solution:
https://github.com/CodeByTushu/CodeByTushu-LeetCode-Solutions/blob/main/solutions/March/1-March/1689-Partitioning-Into-Minimum-Number-Of-Deci-Binary-Numbers/solution.cpp

🌐 JavaScript Solution:
https://github.com/CodeByTushu/CodeByTushu-LeetCode-Solutions/blob/main/solutions/March/1-March/1689-Partitioning-Into-Minimum-Number-Of-Deci-Binary-Numbers/solution.js

πŸ”— LeetCode Source Code

πŸ“Œ Admin type the link

🌐 All LeetCode Solutions

πŸ“Œ https://codebytushu.com/Leetcode/

πŸ“± Join CodeByTushu on WhatsApp

Get coding updates, LeetCode solutions, daily questions and more.

https://whatsapp.com/channel/0029Vb8k5mCDeON2Xwlkxe40

❀️ Donate

πŸ“Œ https://codebytushu.com/Leetcode/donate.php

πŸ”₯ Perfect For

LeetCode Medium Problems
Java DSA Preparation
Greedy Algorithms
Digit Manipulation
String Traversal
Time Complexity Optimization
Coding Interview Preparation
Problem Solving

🌐 Follow CodeByTushu

▢️ YouTube: https://www.youtube.com/@codebytushu

πŸ“Έ Instagram: https://instagram.com/codebytushu/

πŸ’Ό LinkedIn: https://www.linkedin.com/company/codebytushu/

🌍 Website: https://codebytushu.com

πŸ™ GitHub: https://github.com/CodeByTushu

❀️ Don’t Forget To

πŸ‘ Like | πŸ’¬ Comment | πŸ”” Subscribe

πŸ’¬ Question of the Day

Why is the minimum number of deci-binary numbers needed to sum up to n always equal to the maximum digit of n?

1️⃣ Because each deci-binary number contributes at most 1 at each column position
2️⃣ Because binary numbers cannot have carries
3️⃣ Because deci-binary numbers must always be powers of 10
4️⃣ Because the length of n determines the minimum number of summands

#LeetCode1689 #LeetCode #PartitioningIntoMinimumNumberOfDeciBinaryNumbers #Java #JavaDSA #Greedy #String #DSA #CodingInterview #ProblemSolving #LeetCodeMedium #DailyLeetCode #JavaProgramming #CodeByTushu

πŸ‘‡ Comment the answer below! πŸ”₯Β Close description
Β Β Β Β Β Β 
Videos related to "LeetCode 1689 | Partitioning Into Minimum Number Of Deci-Binary Numbers | Java | CodeByTushu"

Related videos are temporarily unavailable.

Try again, or come back later.