Incorrect ans on OJ

  • 0

    My code gives right output in Ideone but is giving wrong ans on OJ:

    class Solution {
        bool isIsomorphic(string s, string t) {
        		return false;
        	map<char, char> temp;
        	map<char, char>::iterator it;
        	for(int i=0; i<s.length(); i++)
        		it = temp.find(s[i]);
          		if (it == temp.end()){
          			temp[s[i]] = t[i];
          			if(it->second !=t[i])
          				return false;
        	return true;

    Test case for which it fails is:

    Input:	"ab", "aa"
    Output:	true
    Expected:	false

    26 / 30 test cases passed.
    Please help.

  • -2

    There is no error in OJ.The 'a' is already replaced by 'a',so it can't be replaced by 'b' again.The result of this testcase should be false.The isIsomorphic relation is by each other.

  • 0

    I know the test case is right. My problem is that this gave expected output when ran on and OJ is giving the output "true".

  • 0

    I have the same issue. Worked on my own pc. But I passed it on OJ by using two hashtables.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.