Visa Inc. interview question

medium level leet code problems