Write a function that takes a string as input and returns the string reversed.
Example 1:
Input: "hello" Output: "olleh"
Example 2:
Input: "A man, a plan, a canal: Panama" Output: "amanaP :lanac a ,nalp a ,nam A"
My solutions:
class Solution:
def reverseString(self, s):
"""
:type s: str
:rtype: str
"""
size = len(s)
result = ""
for i in range(size):
result += s[size - i - 1]
return result
'DataStructure > Strings' 카테고리의 다른 글
String to Integer (atoi) (0) | 2018.10.23 |
---|---|
Valid Palindrome (0) | 2018.10.23 |
Valid Anagram (0) | 2018.10.23 |
First Unique Character in a String (0) | 2018.10.22 |
Reverse Integer (0) | 2018.10.22 |