496. Next Greater Element I

    xiaoxiao2021-03-25  96

    public class Solution { public int[] nextGreaterElement(int[] findNums, int[] nums) { int lf = findNums.length; int[] res = new int[lf]; int i=0,j=0; for(i=0;i<lf;i++) { boolean find = false; for(j=0;j<nums.length;j++) { if(!find && nums[j] == findNums[i]) { find = true; }else if(find&&nums[j]>findNums[i]) { res[i] = nums[j]; break; } } if(j>=nums.length) { res[i] = -1; } } return res; } }
    转载请注明原文地址: https://ju.6miu.com/read-25068.html

    最新回复(0)