Skip to content

1689. Partitioning Into Minimum Number Of Deci-Binary Numbers

  • Time: $O(n)$
  • Space: $O(1)$
1
2
3
4
5
6
class Solution {
 public:
  int minPartitions(string n) {
    return ranges::max(n) - '0';
  }
};
1
2
3
4
5
class Solution {
  public int minPartitions(String n) {
    return Character.getNumericValue(n.chars().max().getAsInt());
  }
}
1
2
3
class Solution:
  def minPartitions(self, n: str) -> int:
    return int(max(n))