Veeva Systems Interview Question

Leetcode Question, find the next greater number, with a following question about simple proof.