Wells Fargo interview question

Leetcode question easy to medium