Reverse String
Question
Write a function that takes a string as input and returns the string reversed.
Example: Given s = "hello", return "olleh".
Tags
- String
Thought
Two solutions: use list or not use index.
Code
class Solution(object):
    def reverseString(self, s):
        """
        :type s: str
        :rtype: str
        """
        ch_list = list(s)
        ch_list.reverse()
        return ''.join(ch_list)
class Solution(object):
    def reverseString(self, s):
        """
        :type s: str
        :rtype: str
        """
        return s[::-1]