水题解 s2 第一场 第三题 class Solution: def Maxsumforknumers(self , x , k ): # write code here stack = [] res = 0 s= 0 for i in range(len(x)): stack.append(int(x[i])) stack.sort(reverse= True) for i in range(k-1): res+=stack[-1] stack.pop() for i in range(len(stack)): s= 10*s+ stack[i] res+=s return res