Leetcode 344: Reverse String

344. Reverse String

  • Total Accepted: 92658
  • Total Submissions: 159447
  • Difficulty: Easy

Write a function that takes a string as input and returns the string reversed.

Example:
Given s = “hello”, return “olleh”.

 

 

Code

class Solution(object):
    def reverseString(self, s):
        """
        :type s: str
        :rtype: str
        """
        return s[::-1]

 

 

Idea

Nothing too much…

 

Leave a comment

Your email address will not be published. Required fields are marked *