ServiceNow interview question

Q: 2 leetcode style problems