I don't know why my code is runtime error


  • 0
    L

    class Solution {
    public:
    bool isIsomorphic(string s, string t) {
    int y;
    int temp1 = new int[sizeof(s)(sizeof(int) - 1)];
    int temp2 = new int[sizeof(t)(sizeof(int) - 1)];
    map<int , char> x1, x2;
    for (int i = 0; s[i] != '\0'&&t[i] != '\0'; i++){
    if (x1.find(s[i]) == x1.end()){
    x1[s[i]] =i;
    temp1[i] =i;
    }
    else{
    temp1[i] =x1.find(s[i])->second;
    }
    if (x2.find(t[i]) == x2.end()){
    x2[t[i]] = i;
    temp2[i] = i;
    }
    else
    temp2[i] = x2.find(t[i])->second;
    y = i+1;
    }
    for (int i = 0; i < y; i++){
    if (temp1[i] != temp2[i])
    return false;
    }
    return true;
    }
    };


Log in to reply
 

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