Horje
496. Next Greater Element I.cpp Code Example
496. Next Greater Element I.cpp
class Solution {
public:
    vector<int> nextGreaterElement(vector<int>& nums1, vector<int>& nums2) {
        vector<int> res;
        for(int i=0;i<nums1.size();i++)
        {
            for(int j=0;j<nums2.size();j++)
            {
                if(nums1[i]==nums2[j])
                {
                    int k;
                    for(k=j+1;k<nums2.size();k++)
                    {
                        if(nums2[k]>nums2[j])
                        {
                            res.push_back(nums2[k]);
                            break;
                        }
                    }
                    if(k==nums2.size())
                        res.push_back(-1);
                    
                    break;
                }
                 
            }
        }
     
        return res;
    }
};




Cpp

Related
>> c++ Code Example >> c++ Code Example
while(n--) Code Example while(n--) Code Example
iterate over map c++17 Code Example iterate over map c++17 Code Example
c++ stoi binary negative number string to decimal Code Example c++ stoi binary negative number string to decimal Code Example
The Three Topics codechef solution in c++ Code Example The Three Topics codechef solution in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9