3019 力扣每日一题 按键变更的次数
class Solution:def countKeyChanges(self, s: str) -> int:n,reslen(s),0for i in range(n-1):if abs(ord(s[i])-ord(s[i1]))32 or ord(s[i])ord(s[i1]):continueelse:res1return res这道题是一个简单的遍历ord函数可以看出两个字符的ascii码 大写字母和器3对应的小写字母差…
2025-01-24