Tap here to switch tabs
Problem
Submissions

Problem: Number of Changing Keys

med
30 min
Try to solve the Number of Changing Keys problem.

Statement

You are given a string s typed by a user. Changing a key is defined as typing a character that is different from the immediately preceding character, ignoring letter casing.

Return the number of times the key was changed while typing s.

Note: Modifiers such as Shift or Caps Lock do not count toward a key change. For instance, typing 'a' followed by 'A' uses the same key.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • s consists of only upper case and lower case English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Changing Keys

med
30 min
Try to solve the Number of Changing Keys problem.

Statement

You are given a string s typed by a user. Changing a key is defined as typing a character that is different from the immediately preceding character, ignoring letter casing.

Return the number of times the key was changed while typing s.

Note: Modifiers such as Shift or Caps Lock do not count toward a key change. For instance, typing 'a' followed by 'A' uses the same key.

Constraints:

  • 1≤1 \leq s.length ≤100\leq 100

  • s consists of only upper case and lower case English letters.