Okta interview question

I was asked to solve a LeetCode medium question live.