Problem: http://ift.tt/1YqTcYO
Solution: http://ift.tt/2deTMbH
Input: ["s","sssll"]
When i=1 in nested loop and left = "s", right = "ssll" the below if condition is satisfied.
if(dict.find(left) != dict.end() && isPalindrome(right) && dict[left] != i)
The below statement in if part should get executed
ans.push_back({i, dict[left]});
The if condition is satisfied but still [0,1] is not printed in answer.
I understand that string formed by concatenating words[0]+words[1]="ssssll" is not a palindrome;so it should not be the part of answer. But I don't understand why doesn't the if part get executed when the specified condition is met.
What have I misunderstood?
Aucun commentaire:
Enregistrer un commentaire