Ad
Fundamentals
Strings
Code
Diff
  • reverse_string = lambda string: "".join(reversed(string))
    • reverse_string = lambda string: string[::-1]
    • reverse_string = lambda string: "".join(reversed(string))
Code
Diff
  • from collections import deque
    
    def test():
        dequedStr = deque("test")
        return ''.join([dequedStr.popleft() for x in range(len(dequedStr))])
    • from itertools import compress
    • from collections import deque
    • def test():
    • string = "letters inside a string"
    • digits = [0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0]
    • result = compress(string, digits)
    • return ''.join(list(result))
    • dequedStr = deque("test")
    • return ''.join([dequedStr.popleft() for x in range(len(dequedStr))])
Fundamentals
Strings
Code
Diff
  • def reverse_string(string):
        return string[::-1]
    • from collections import deque
    • def reverse_string(string):
    • dequed_str = deque(string)
    • return ''.join([dequed_str.pop() for _ in range(len(dequed_str))])
    • return string[::-1]