Caps Lock Typing
Easy · two pointers
Ines is typing on an old keyboard whose Caps Lock is controlled by the ^ key. Every press of ^ switches Caps Lock on if it is off, and off if it is on. It starts off.
While Caps Lock is off, a letter key writes the letter in lowercase. While it is on, the same key writes it in uppercase. The ^ key itself writes nothing.
You are given the string typed, the keys Ines pressed in order (lowercase letters and ^ only), and the string target, the text she wanted to produce. Return true if the text her keys actually produce is exactly target, otherwise false.
Examples
Example 1
Input: typed = "ab^cd^e", target = "abCDe"
Output: true
Caps Lock is on only while c and d are typed, so the text is abCDe.
Example 2
Input: typed = "a^b", target = "ab"
Output: false
The b is typed with Caps Lock on, so it comes out as B.
Example 3
Input: typed = "^^a", target = "a"
Output: true
Constraints
- 1 <= len(typed) <= 10^5
- 0 <= len(target) <= 10^5
- typed contains only lowercase letters and the character ^.
- target contains only lowercase and uppercase letters.