Teza Technologies interview question

solve leet code type of questions in Python