Vector Institute Interview Question

it is based on the problem statement