Wells Fargo Interview Question

Based on the dsa problems