Skip to main content

2810. Faulty Keyboard - LeetCode

class Solution:
def finalString(self, s: str) -> str:
buf = []
for c in s:
if c == 'i':
buf = buf[::-1]
else:
buf.append(c)
return ''.join(buf)