~~~~~↵
Your code here...↵
~~~~~↵
↵
I have tried this q :[Aquamoon and Stolen String](https://codeforces.com/problemset/problem/1546/B)↵
↵
And wrote the following code:↵
↵
<spoiler summary="CODE">↵
~~~~~↵
#include<bits/stdc++.h>↵
using namespace std; ↵
↵
int main()↵
{↵
ios_base::sync_with_stdio(false);↵
cin.tie(NULL);cout.tie(NULL);↵
long long T;↵
cin >> T;↵
for(long long _ = 1;_<=T;_++)↵
{ ↵
int n,m;↵
cin>>n>>m;↵
vector<vector<int>> ar( 100005 , vector<int> (30, 0));↵
for(int i=0;i<n;i++)↵
{↵
string s;↵
cin>>s;↵
for(int j=0;j<m;j++){↵
int mr = s[j] — 'a';↵
ar[j][mr]++;↵
}↵
}↵
for(int i=0;i<n-1;i++)↵
{↵
string s;↵
cin>>s;↵
for(int j=0;j<m;j++){↵
int mr = s[j] — 'a';↵
ar[j][mr]--;↵
}↵
}↵
string ans;↵
for(int i=0;i<m;i++)↵
{↵
for(int j=0;j<26;j++)↵
{↵
if(ar[i][j]>0){↵
char t = 97+j;↵
ans.push_back(t);↵
}↵
}↵
}↵
cout<<ans<<endl;↵
}↵
return 0;↵
}↵
~~~~~↵
</spoiler>↵
↵
↵
As per what I can observe my code is O(n*m) and in the q its mentioned that It is guaranteed that n is odd and that the sum of n⋅m over all test cases does not exceed 10^5.↵
↵
But still my code is giving TLE in test case 2.↵
↵
plz help me with its complexity↵
↵
Your code here...↵
~~~~~↵
↵
I have tried this q :[Aquamoon and Stolen String](https://codeforces.com/problemset/problem/1546/B)↵
↵
And wrote the following code:↵
↵
<spoiler summary="CODE">↵
~~~~~↵
#include<bits/stdc++.h>↵
using namespace std; ↵
↵
int main()↵
{↵
ios_base::sync_with_stdio(false);↵
cin.tie(NULL);cout.tie(NULL);↵
long long T;↵
cin >> T;↵
for(long long _ = 1;_<=T;_++)↵
{ ↵
int n,m;↵
cin>>n>>m;↵
vector<vector<int>> ar( 100005 , vector<int> (30, 0));↵
for(int i=0;i<n;i++)↵
{↵
string s;↵
cin>>s;↵
for(int j=0;j<m;j++){↵
int mr = s[j] — 'a';↵
ar[j][mr]++;↵
}↵
}↵
for(int i=0;i<n-1;i++)↵
{↵
string s;↵
cin>>s;↵
for(int j=0;j<m;j++){↵
int mr = s[j] — 'a';↵
ar[j][mr]--;↵
}↵
}↵
string ans;↵
for(int i=0;i<m;i++)↵
{↵
for(int j=0;j<26;j++)↵
{↵
if(ar[i][j]>0){↵
char t = 97+j;↵
ans.push_back(t);↵
}↵
}↵
}↵
cout<<ans<<endl;↵
}↵
return 0;↵
}↵
~~~~~↵
</spoiler>↵
↵
↵
As per what I can observe my code is O(n*m) and in the q its mentioned that It is guaranteed that n is odd and that the sum of n⋅m over all test cases does not exceed 10^5.↵
↵
But still my code is giving TLE in test case 2.↵
↵
plz help me with its complexity↵
↵