class Solution: def string2(self , k , s ): a=[ord(i) for i in "qwertyuiopasdfghjklzxcvbnm"] b=[ord(i) for i in s] result=0 for i in a: b.sort(key=lambda x:abs(i-x)) current=0 c=k for j in b: if c>=abs(i-j): c-=abs(i-j) current+=1 else: break result=max(result,current) return result
全部评论
(0) 回帖