Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.09 KB

_1689. Partitioning Into Minimum Number Of Deci-Binary Numbers.md

File metadata and controls

54 lines (40 loc) · 1.09 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 22, 2024

Last updated : June 22, 2024


Related Topics : String, Greedy

Acceptance Rate : 88.76 %


Solutions

C

int minPartitions(char* n) {
    int output = 0;
    
    while (*n) {
        output = *n - '0' < output ? output : (*n - '0');
        n++;
    }

    return output;
}

Java

class Solution {
    public int minPartitions(String n) {
        int maxx = 0;

        for (char c : n.toCharArray()) {
            maxx = Integer.max(maxx, c - '0');
        }
        return maxx;
    }
}