Cognizant Interview Question

To solve a DSA question while explaining our intuition