Twilio interview question

leetcode question - easy difficulty