Oracle Interview Question

DSA problem with medium difficulty