Practice Number of Changing Keys
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a 0-indexed string s typed by a user. Changing a key is defined as using a key different from the last used key. For example, s = "ab" has a change of a key while s = "bBBb" does not have any. Return the number of times the user had to change the key. Note: Modifiers like shift or caps lock won't be counted in changing the key that is if a user typed the letter 'a' and then the letter 'A' then it will not be considered as a changing of key.
Source: Number of Changing Keys on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
s = "aAbBcC"
2
# Example 2
s = "AaAaAaaA"
0
Constraints
Related LeetCode Problems
Practice more problems similar to Number of Changing Keys.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.