题目描述:
https://leetcode-cn.com/problems/next-greater-element-i/
Java代码:
class Solution {
public int[] nextGreaterElement(int[] nums1, int[] nums2) {
int[] answer=new int[nums1.length];
for(int i=0,j;i<nums1.length;i++){
answer[i]=-1;
for(j=0;j<nums2.length&&nums1[i]!=nums2[j];j++);
for(j=j+1;j<nums2.length;j++){
if(nums2[j]>nums1[i]){
answer[i]=nums2[j];
break;
}
}
}
return answer;
}
}