Avaya Interview Question

one is logic question, another is from the leetcode