public void function(int[] nums){ int LEN = nums.length; for (int i = LEN - 1;i >= 0;i--){ while (!stack.empty() && nums[i] > stack.peek()){ stack.pop(); } stack.push(nums[i]); } }