Avaya interview question

one is logic question, another is from the leetcode