Plivo Interview Question

Stack-based medium problem was asked.