Can i solve Lapindrome problem without using map function (in c++) ?

problem link:

I did it without the use of map or vector or array .

I simply ran a loop over all the elements of the string, but now I can tell you that it wouldâ€™ve been much easier if you used vector/array/map .

If you need an explanation for my solution reply to this message and I will explain it -

https://www.codechef.com/viewsolution/33071297

Again, the code would have been much shorter with the use of array although the time complexity wouldâ€™ve been same (but using map space complexity would be more) .

Invalid solution id showing!

@shubhamkumar68

#include<bits/stdc++.h>

using namespace std;

int main()

{

int t;

for(cin>>t;t;â€“t)

{

string s,r1,r2;

cin>>s;

int len=s.length();

if(len%2!=0)

{ for(int i=0;i<len/2;++i)

r1.push_back(s[i]);

for(int i=len/2+1;i<len;++i)

r2.push_back(s[i]);

sort(r1.begin(),r1.end());

sort(r2.begin(),r2.end());

if(r1.compare(r2)==0) cout<<â€śYES\nâ€ť;

else cout<<â€śNO\nâ€ť;

}

else

{

for(int i=0;i<len/2;++i)

r1.push_back(s[i]);

for(int i=len/2;i<len;++i)

r2.push_back(s[i]);

sort(r1.begin(),r1.end());

sort(r2.begin(),r2.end());

if(r1.compare(r2)==0) cout<<â€śYES\nâ€ť;

else cout<<â€śNO\nâ€ť;

}

}

return 0;

}`

Check this it will Help youâ€¦

https://www.codechef.com/viewsolution/30878373

Hope it helps you.It is in java but you can understand the logic.

sorry . I have edited the link , take a look again .

Here is a very simple solution without using map/vector/arrays etc.