Cisco interview question

Leetcode 809 is the coding question.