Skip to content

Commit 41d2f98

Browse files
committed
Add solution #1689
1 parent a4a486d commit 41d2f98

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,476 LeetCode solutions in JavaScript
1+
# 1,477 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1301,6 +1301,7 @@
13011301
1686|[Stone Game VI](./solutions/1686-stone-game-vi.js)|Medium|
13021302
1687|[Delivering Boxes from Storage to Ports](./solutions/1687-delivering-boxes-from-storage-to-ports.js)|Hard|
13031303
1688|[Count of Matches in Tournament](./solutions/1688-count-of-matches-in-tournament.js)|Easy|
1304+
1689|[Partitioning Into Minimum Number Of Deci-Binary Numbers](./solutions/1689-partitioning-into-minimum-number-of-deci-binary-numbers.js)|Medium|
13041305
1716|[Calculate Money in Leetcode Bank](./solutions/1716-calculate-money-in-leetcode-bank.js)|Easy|
13051306
1718|[Construct the Lexicographically Largest Valid Sequence](./solutions/1718-construct-the-lexicographically-largest-valid-sequence.js)|Medium|
13061307
1726|[Tuple with Same Product](./solutions/1726-tuple-with-same-product.js)|Medium|
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* 1689. Partitioning Into Minimum Number Of Deci-Binary Numbers
3+
* https://leetcode.com/problems/partitioning-into-minimum-number-of-deci-binary-numbers/
4+
* Difficulty: Medium
5+
*
6+
* A decimal number is called deci-binary if each of its digits is either 0 or 1 without any
7+
* leading zeros. For example, 101 and 1100 are deci-binary, while 112 and 3001 are not.
8+
*
9+
* Given a string n that represents a positive decimal integer, return the minimum number of
10+
* positive deci-binary numbers needed so that they sum up to n.
11+
*/
12+
13+
/**
14+
* @param {string} n
15+
* @return {number}
16+
*/
17+
var minPartitions = function(n) {
18+
let maxDigit = 0;
19+
for (const digit of n) {
20+
maxDigit = Math.max(maxDigit, parseInt(digit));
21+
}
22+
return maxDigit;
23+
};

0 commit comments

Comments
 (0)