My solution iterates through the array once, so the time complexity is O(n), and since I only use a single variable to store the sum, the space complexity is O(1).” Sorting a List: “I used Python’s built-in sort() which implements Timsort, giving an average time complexity of O(n log n) and space complexity of O(n) in the worst case.”
Sigiloso
"I used a set to track seen elements. I loop through the list once, so the time complexity is O(n). Since I store up to all elements in a set, the space complexity is also O(n)."