Pergunta de entrevista da empresa Okta

I was asked to solve a LeetCode medium question live.