class Solution {
public:
vector<int> nextGreaterElement(vector<int>& findNums, vector<int>& nums) {
vector<int> greater;
for(int n = 0; n < findNums.size(); n++)
{
bool bfind = false;
int nNum = findNums[n];
vector<int>::iterator ifind = find(nums.begin(), nums.end(), findNums[n]);
int m = 0;
for(m = distance(nums.begin(), ifind) ; m < nums.size(); m++)
{
if(nums[m] > findNums[n])
{
bfind = true;
break;
}
}
if(bfind == true)
{
greater.emplace_back(nums[m]);
}
else
{
greater.emplace_back(-1);
}
}
return greater;
}
};
相关文章
- 03-15496. Next Greater Element I
- 03-15leetcode算法:Next Greater Element I
- 03-15leetcode 496, 503, 556. Next Greater Element I, II, III | 496, 503, 556. 下一个更大元素 I,II,III(单调栈)
- 03-15[LeetCode] 556. Next Greater Element III
- 03-15556. Next Greater Element III
- 03-15LeetCode 556. 下一个更大元素 III(Next Greater Element III)
- 03-15503. Next Greater Element II 首尾可循环
- 03-15556. Next Greater Element III
- 03-15556. Next Greater Element III
- 03-15496. Next Greater Element I (单调栈)