Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 430 Bytes

344.md

File metadata and controls

32 lines (22 loc) · 430 Bytes

Reverse String

Description

link


Solution

  • code

Code

class Solution:
    def reverseString(self, s):
        """
        :type s: str
        :rtype: str
        """
        s = list(s)
        n = len(s)
        for i in range(n//2):
            s[i], s[~i] = s[~i], s[i]
        
        return "".join(s)

        # return s[::-1]