Reverse String 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 더보기 Remove Duplicates from Sorted Array Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.Example 1:Given nums = [1,1,2], Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't ma.. 더보기 LRU Cache Design and implement a data structure for LRU (Least Recently Used) cache. It should support the following operations: get and set.get(key) - Get the value (will always be positive) of the key if the key exists in the cache, otherwise return -1.set(key, value) - Set or insert the value if the key is not already present. When the cache reaches its capacity, it should invalidate the least recently.. 더보기 이전 1 ··· 9 10 11 12 13 14 15 ··· 53 다음