Optoro interview question

Leetcode medium