Wells Fargo interview question

Based on the dsa problems