Infosys interview question

Comparable and Comparator coding question