一刷 06/2022
Time O(Len)
Space O(1)
Runtime: 9 ms, faster than 63.10% of Java online submissions for Partitioning Into Minimum Number Of Deci-Binary Numbers.
Memory Usage: 54.4 MB, less than 31.55% of Java online submissions for Partitioning Into Minimum Number Of Deci-Binary Numbers.
class Solution {
public int minPartitions(String n) {
int max = 0;
for (int i = 0; i < n.length(); i++) {
max = Math.max(max, n.charAt(i) - '0');
}
return max;
}
}
No comments:
Post a Comment