All the discussions here are based on my own experience while giving assessment test on hackerrank. I am only discussing my approach which I used in coding assessment test. Hackerrank Profile: https://www.hackerrank.com/KLU_180031058