Faulty Keyboard
Your laptop keyboard is faulty, and whenever you type a character 'i' on it, it reverses the string that you have written. Typing other characters works as expected.
You are given a 0-indexed string s, and you type each character of s using your faulty keyboard.
Return the final string that will be present on your laptop screen.
Example 1
Input
s = "string"Output
"rtsng"Typing characters from
s builds str, the fourth character 'i' reverses it to rts, and the remaining characters produce rtsng.Example 2
Input
s = "poiinter"Output
"ponter"The two consecutive
'i' characters reverse the current text twice, returning it to po, and the remaining characters produce ponter.Constraints
- 1 <= s.length <= 100
- s consists of lowercase English letters.
- s[0] != 'i'