Cisco interview question

two easy to medium leetcode problems.