Coding test

[Leetcode] 1689. Partitioning Into Minimum Number Of Deci-Binary Numbers - javascript

Jiwoo 2022. 7. 6. 09:56

📝 문제

A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112 and 3001 are not.

Given a string n that represents a positive decimal integer, return the minimum number of positive deci-binary numbers needed so that they sum up to n.

 

문제 더보기

 

🔑 나의 풀이

var minPartitions = function(n) {
    let answer = 0;
    for(let i = 0; i < n.length; i++) {
        answer = answer < n[i] ? n[i] : answer;
    }
    return answer;
};

 

  • 정확도 테스트 결과