class Solution(object):
def reverseString(self, s):
l = len(s)
if l < 2:
return s
return self.reverseString(s[l/2:]) + self.reverseString(s[:l/2])
class SolutionClassic(object):
def reverseString(self, s):
r = list(s)
i, j = 0, len(r)  1
while i < j:
r[i], r[j] = r[j], r[i]
i += 1
j = 1
return "".join(r)
class SolutionPythonic(object):
def reverseString(self, s):
return s[::1]
Python (3 solutions: Recursive, Classic, Pythonic)


@Gclalaboo
Leetcode supports only python 2.7.12, so there is no "//" operator. If you was confused by topic title Python 3 solutions, 3 goes to solutions count :)


@hanumegowda
I guess it should be here, butfloor
will return youfloat
. It's not what we need,/
is the best option. And usingfloor
probably should be slower.


@hanumegowda
Typecasting in this case is not what we need. It's too much action./
in python2 is an integer division if both inputs are integers, that' what we have in our case. Just compare7 / 2 = 3
andint(math.floor(7/2))
. It even looks scary.
