hi I got a really simple problem "write a function that reorders a list so that all lowercase letter appear first and afterward uppercase letters " for example [‘K’, ‘f’, ‘H’, ‘T’, ‘m’] will turn to [‘m’, ‘f’, ‘H’, ‘T’, ‘K’] (letters order doesn’t matter as long as lowercase letters appear first)
so the time complexity of my solution is O(n) but what is the space complexity?(required to be O(1)).
also if someone could tell me how to know more in general how to tell the space complexity of a function?
def sortt(lst): new_lst= for letter in lst: if ord(letter)>=ord("a") and ord(letter) <=ord("z"): new_lst.append(letter) for letter in lst: if ord(letter) >=ord("A") and ord(letter)<=ord("Z"): new_lst.append(letter) return new_lst print(sortt(['K', 'f', 'H', 'T', 'm']))