why is this code giving an out of scope error for visited array in the last for loop.

#include<bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
vector stren;
int N;
cin >> N;
vector<vector> visited(N+1,vector(N+1));
for (int i = 0; i <=N; i++)
{
for (int j = 0; j <= N; j++)
{
visited[i][j]=0;
}
}
for (int i = 0; i < N; i++)
{
int temp;
cin >> temp;
stren.push_back(temp);
}
long sum = 0;

for (int i = 0; i <N; i++)
{
	for (int j = 0; j < N-1; j++)
	{ 
	if (visited[i][j]==0)
		{
			sum += abs(stren[i] - stren[j]);
			visted[i][j]=1;
		}
	}
}
cout << sum;
return 0;

}

Because you’ve never declared a variable called “visted” - it’s a simple typo. You meant to write “visited”.