10 lines C solution, without hash table

  • 5
    bool isIsomorphic(char* s, char* t){
    		return false;
    	char *spt = s, *tpt=t;
    	while(*spt != '\0'){
    		if( strchr(s, *spt++)-s != strchr(t, *tpt++)-t)
    			return false;
    	return true;

    Two strings s and t are not isomorphic if for every index i, s[i] and t[i] first appear in string s and t, respectively, in different position.

Log in to reply

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