public class Solution { public int[] NextGreaterElement(int[] findNums, int[] nums) { var list = new List<int>(); foreach (var num in findNums) { for (int i = 0; i < nums.Length; i++) { if (num == nums[i]) { var cur = -1; for (int j = i + 1; j < nums.Length; j++) { if (nums[j] > num) { cur = nums[j]; break; } } list.Add(cur); } } } //foreach (var l in list) //{ // Console.WriteLine(l.ToString()); //} return list.ToArray(); } }
https://leetcode.com/problems/next-greater-element-i/#/description