Problem Statement
All the alphabetical keys on your keyboard are broken. Given a String word, return the minimal number of keys you must repair to be able to type word.
Definition
- Class:
- BrokenKeyboardRepair
- Method:
- minimalNumberOfKeys
- Parameters:
- String
- Returns:
- int
- Method signature:
- int minimalNumberOfKeys(String word)
- (be sure your method is public)
Constraints
- word will contain between 1 and 50 characters, inclusive.
- word will contain only lowercase letters ('a'-'z').
Examples
"coder"
Returns: 5
You have to repair the following keys: 'c', 'd', 'e', 'o', 'r'."hello"
Returns: 4
You have to repair the following keys: 'e', 'h', 'l', 'o'."abracadabra"
Returns: 5
You have to repair the following keys: 'a', 'b', 'c', 'd', 'r'.