I have tried to implement without trie, but did not get the desired result. Can anyone please help.
Error in ENGLISH
Hello @koulick424. Here are a few bugs I found:

check():@line 25
 Sincer
is negative, you’re accessing characters at negative indices ofstr1
andstr2
. Maybe you meant:
while(i<m && r>=m && s1[i]==s2[i] && s1[s1.length()+r]==s2[s2.length()+r]){

solve():@line 79
 I’m sorry, I don’t quite understand how you’re intending to usemap mo
because you’re losing the contribution of the previous value which had keyk
every time a pair pops up with the same value ask
and I don’t see it getting resolved. 
solve():@line 91
 Sinceset se
is initially empty, theif
condition will always evaluate tofalse
. So,ans
will contain nothing but the contribution of the pairs of equal strings. Maybe you meant:
if(se.find(it>second.first)==se.end() and se.find(it>second.second)==se.end()){
Here's a testcase where your program produces an incorrect result
It taking advantage of bug number 2
5
ab
acb
adcdb
asfaffb
aergwhrb
Your program produces:
1
The response should be:
2
Hope this was helpful.
1 Like