3312. Number of Changing Keys
My accepted Python solution to LeetCode problem 3312, Number of Changing Keys, running in 2ms.
- Difficulty: Easy
- Python
- Runtime 2ms
- Memory 17MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 2ms, memory 17MB, accepted 2025-12-30.
class Solution:
def countKeyChanges(self, s: str) -> int:
return sum(1 for i in range(1, len(s)) if s[i].lower() != s[i-1].lower())