Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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;
    }
};
Comment

PREVIOUS NEXT
Code Example
Cpp :: dijkstra algorithm in c++ geeksforgeeks 
Cpp :: converting a for loop to a while loop C++ 
Cpp :: C++ initializing a thread with a class/object with parameters 
Cpp :: dualSort 
Cpp :: c++ server service ros 
Cpp :: Overloading IO Stream 
Cpp :: ex:c++ gcc start adress 
Cpp :: online computer graphics compiler c++ 
Cpp :: c++ max function 
Cpp :: double pointers C++ 
Cpp :: c++ multi-dimensional arrays 
Cpp :: middle node of linked list 
Cpp :: function template in c++ 
Cpp :: array list cpp 
Cpp :: what does | mean in c++ 
Cpp :: function overloading in cpp 
Cpp :: nazi crosshair c++ 
C :: hello word c 
C :: fahrenheit to celsius formula 
C :: Sorting number excluding elements in highest to lowest 
C :: variably modified ‘_memory’ at file scope 
C :: line counter in c 
C :: size of an array c 
C :: find the largest number among five numbers in c language 
C :: hashmap c 
C :: c assign pointer to struct 
C :: Graphics in C Draw Circle 
C :: strong number in c 
C :: append to list in c 
C :: putchar in c 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =