https://leetcode.com/problems/reverse-string/ Hey there, I'm doing reverse the string on leetcode and this is the solution.
def reverseString(self, s):
"""
:type s: List[str]
:rtype: None Do not return anything, modify s in-place instead.
"""
s[:] = s[::-1]
The part that I'm not understanding is s[:]. Why do we need that? From what I was thinking, we could simply do:
s = s[::-1]
Not understanding this and hoping someone could guide me. Thank you!