class Solution(object): def reverseString(self, s): """ :type s: str :rtype: str """ return s[::-1]
In case anyone wondered, it's called Extended Slices
That's my answer too. HOWEVER, I ended up 55% faster than other python solutions. I'm wondering what's a faster one.
Would this be an okay solution during an interview or do they usually prefer actually coding it out like the other top solutions
s1 = list(s) s1.reverse() return ''.join(s1)
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.