fork download
  1. vector<int> l(n, -1), r(n, n);
  2. stack<int> s;
  3.  
  4. for (int i = 0; i < n; i++)
  5. {
  6. while (s.size() && arr[s.top()] < arr[i]) // If equal on right => can extend
  7. {
  8. r[s.top()] = i;
  9. s.pop();
  10. }
  11.  
  12. if (s.size()) // If equal on left => CANNOT extend
  13. l[i] = s.top();
  14.  
  15. s.push(i);
  16. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:1: error: ‘vector’ does not name a type
 vector<int> l(n, -1), r(n, n);
 ^~~~~~
prog.cpp:2:1: error: ‘stack’ does not name a type
 stack<int> s;
 ^~~~~
prog.cpp:4:1: error: expected unqualified-id before ‘for’
 for (int i = 0; i < n; i++)
 ^~~
prog.cpp:4:17: error: ‘i’ does not name a type
 for (int i = 0; i < n; i++)
                 ^
prog.cpp:4:24: error: ‘i’ does not name a type
 for (int i = 0; i < n; i++)
                        ^
stdout
Standard output is empty