2ms C accepted


  • 0
    G
    bool isIsomorphic(char* s, char* t) 
    {
        char mapAll[128] = "";
    	int nLen = strlen(s);
    	int i = 0;
    	for (i=0; i<nLen; i++)
    	{
    		if(mapAll[s[i]] == 0)
    		{
    			mapAll[s[i]] = t[i];
    			if(i >0 && mapAll[s[i]] == mapAll[s[i-1]])
    				return false;
    			continue;
    		}
    		if(mapAll[s[i]] != t[i])
    			return false;
    	}
    	return true;
    }

  • 0
    V

    Are you sure of your acception? I got a little confused.
    Think about case s = { 'a', 'b', 'c' }, t = { 'a', 'b', 'a' }


  • 0
    Y

    i think you're right. the function returns true. the test cases might be incomplete


  • 0
    T

    mapAll[s[i]] == mapAll[s[i-1]])
    what dose that mean


Log in to reply
 

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