UBS Interview Question

LeetCode - medium question to answer