Ctrl K

The Flip Key

Easy
The i key on a keyboard is broken: instead of typing a letter, it reverses all the text typed so far. Every other key works normally. You press the keys listed in the string keys, one after another. Return the text that ends up on the screen.
Example 1
keys='coding' → 'docng'

After "cod" the i is pressed and the text turns into "doc"; then n and g are added, giving "docng".

Example 2
keys='kiwi' → 'wk'

k gives "k"; i gives "k"; w gives "kw"; i gives "wk".

Example 3
keys='plaza' → 'plaza'

There is no i, so the text is typed as is.

Constraints
  • 1 ≤ len(keys) ≤ 100
  • keys consists of lowercase English letters
  • keys[0] ≠ 'i'
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsSum of Binary Strings EasyCounting Off by Threes and Fives EasyAdding Long Numbers in Strings EasyDrone Back on the Pad EasySame Text After Erasing Easy
loading Python…
Input
keys='coding'
Expected
'docng'

Run checks the first 3 tests in your browser. Submit checks all 144 tests on the server, hidden ones included.