# What is the error in my code

#include <bits/stdc++.h>
using namespace std;

class Solution {
public:
vector nextsmallestno(vector arr, int n) {
stack s;
vector ans(n);
s.push(-1);
for (int i = n - 1; i >= 0; iā) {
while (s.top() != -1 and arr[s.top()] >= arr[i]) {
s.pop();
}
ans[i] = s.top();
s.push(i);
}
return ans;
}

``````vector<int> prevsmallestno(vector<int> arr, int n) {
stack<int> s;
vector<int> ans(n);
s.push(-1);
for (int i = 0; i < n; i++) {
while (s.top() != -1 and arr[s.top()] >= arr[i]) {
s.pop();
}
ans[i] = s.top();
s.push(i);
}
return ans;
}

int largestRectangleArea(vector<int>& heights) {
int n = heights.size();
vector<int> rs(n);
rs = nextsmallestno(heights, n);
vector<int> ls(n);
ls = prevsmallestno(heights, n);
int Maxarea = INT_MIN;
int area;
for (int i = 0;  i < n; i++) {
if (rs[i] == -1) {
rs[i] = n;
}
area = (rs[i] - ls[i] - 1) * heights[i];
Maxarea = max(area, Maxarea);
}
return Maxarea;
}
``````

};

int main() {
Solution s;
int n;
cin>>n;
vector heights(n);
for(int i=0;i<n;i++){
int no;
cin>>no;
heights[i]=no;
}
int result = s.largestRectangleArea(heights);
cout << result;

}

hi @shivamm2110 use long long int