String & 2D vector
String ->Collection of characters string s; //cin >> s ; //cout c ; s.push_back(c); } s.pop_back() ; cout

String ->Collection of characters
string s;
//cin >> s ;
//cout << s << '\n' ;
for(int i = 0 ; i < n ; i++)
{
char c;
cin >> c ;
s.push_back(c);
}
s.pop_back() ;
cout << s ;
cout << s.front() << " " << s.back() << '\n' ;
s.clear() ;
cout << s.empty() << '\n' ;
}
string s;
cin >> s ;
cout << s.substr(1,3) << '\n' ;
cout << s.substr(2) << '\n' // 2 to last TC- O(N)
2D vector structure
Vector inside a vector
#include
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// int n , m;
// cin >>n >> m ;
// vector> v(n,vector(m,5)) ;
// for(int i = 0 ; i < n ;i++)
// {
// int m ;
// cin >> m ;
// vector a;
// for(int j = 0 ; j < m ; j++)
// {
// int x ;
// cin >> x ;
// a.push_back(x) ;
// }
// for(auto value: a){
// cout << value << " " ;
// }
// cout << '\n' ;
// v.push_back(a) ;
// }
// for(int i = 0 ; i < n ; i++)
// {
// for(int j = 0 ; j > n;
vector v;
for (int i = 1; i <= n; i++)
{
string s;
cin >> s;
v.push_back(s);
}
for (int i = 0; i < n; i++)
{
// cout << v[i] << '\n' ;
for (int j = 0; j < v[i].size(); j++)
{
cout << v[i][j] << " ";
}
cout << '\n';
}