Amazon Interview Question

it was an assessment on hackerank