C++code easy to understand


  • 0
    G

    '''

    vector<int> nextGreaterElement(vector<int>& findNums, vector<int>& nums) 
    {
    
    
        vector<int>temp;
    
    for (int i = 0; i < findNums.size(); ++i)
    {
    	auto point = find(nums.begin(), nums.end(), findNums[i]);
    	for (auto j = point; j < nums.end(); ++j)
    	{
    		if (*j > findNums[i])
    		{
    			temp.push_back(*j);
    			break;
    		}
    		if (j == nums.end() - 1)
    			temp.push_back(-1);
    	}
    }
    return temp;
    }

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.