LeetCode solutions

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

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 2ms, memory 17MB, accepted 2025-12-30.

python
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())

Source