Next Greater Integer Leetcode Contest Solution