Why is it giving segmentation fault?

Because of line 40 ,
You are doing cin>>v[i][j] but v[i][j] does not exist
For that create vector like this
vector< vector<int> > v(k,vector<int>(n));
This will create 2d matrix of size kxn

Hey @Ak07
I hope your doubt is resolved ,if its then please mark it as resolved :slight_smile:
If its not then let me know the issue.