General Motors (GM) Interview Question

Two pointer leet code question