znt-Richter Interview Question

Solve the programming problem and explaining on it