题目
代码
执行用时:92 ms, 在所有 Python3 提交中击败了39.44% 的用户
内存消耗:15.2 MB, 在所有 Python3 提交中击败了66.90% 的用户
通过测试用例:97 / 97
class Solution:
def minPartitions(self, n: str) -> int:
cnt=Counter(str(n))
return int(max(cnt))
【方法2】
执行用时:432 ms, 在所有 Python3 提交中击败了5.63% 的用户
内存消耗:15.2 MB, 在所有 Python3 提交中击败了64.79% 的用户
通过测试用例:97 / 97
class Solution:
def minPartitions(self, n: str) -> int:
ans=0
right=len(n)-1
while right>=0:
ans=max(ans,int(n[right]))
right-=1
return ans