Whenever you're ready, walk me through how you'd approach this.
Can you explain the time complexity of your solution, and briefly justify the space complexity as well? Walk through how the code structure leads to that result.