Leet503. 下一个更大元素 II(Next Greater Element II)

https://leetcode-cn.com/problems/next-greater-element-ii/description/

class Solution {
public int[] nextGreaterElements(int []nums)
    {
        int res[]=new int[nums.length];
        if(nums.length==0)
        {
            return res;
        }
        {
            for(int i=0;itemp)
                    {
                        res[i]=nums[j];
                        flag=0;
                        break;
                    }
                }
                if(flag==1)
                {
                    for(int k=0;ktemp)
                        {
                            res[i]=nums[k];
                            flag=0;
                            break;
                        }
                    }
                }
                if(flag==1)
                {
                    res[i]=-1;
                }
            }
        }
        return res;
    }
}

 

你可能感兴趣的:(Java,算法与数据结构)