Thinkify interview question

Leet Code Question Number 92