ServiceNow interview question

2 Leetcode style coding questions.