ServiceNow interview question

coding question, it was done via hackerrank