Skip to content

Instantly share code, notes, and snippets.

Created Jul 10, 2020
What would you like to do?
#define vector<int> vi;vi NGE(vi a){ stack<int>s; vi next(a.size()); int n = a.size(); for(int i = n-1; i >= 0; i--) { while(!s.empty() && <= a[i]) s.pop(); if(s.empty()) next[i] = -1; else next[i] =;
s.push(a[i]); }
return next;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment