UBS Interview Question

Leetcode ez question. Java. Sort.