v6 time O(n) space O(n) Accepted