2 Stacks || C++
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
    O(N)

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
    O(N)

# Code
```cpp []
class Solution {
public:
    vector<int> secondGreaterElement(vector<int>& nums) {
        int n = nums.size();  
        stack<int> noNextGreaterElement , foundNextGreaterElement , temporary;
        vector<int> answer(n , -1);
        for(int i = 0 ; i < n ; i++){
            // step 3
            while(!foundNextGreaterElement.empty() && nums[foundNextGreaterElement.top()] < nums[i]){
                int topElementIdx = foundNextGreaterElement.top();
                foundNextGreaterElement.pop();
                answer[topElementIdx] = nums[i];
            } 

            // step 1
            while(!noNextGreaterElement.empty() && nums[noNextGreaterElement.top()] < nums[i]){
                int topElementIdx = noNextGreaterElement.top();
                noNextGreaterElement.pop();
                temporary.push(topElementIdx);
            }

            // step 2
            while(!temporary.empty()){
                int topElementIdx = temporary.top();
                temporary.pop();
                foundNextGreaterElement.push(topElementIdx);
            }

            noNextGreaterElement.push(i);
        }
        return answer;
    }
};
```
['C++']