Why it is "Memory Limit Exceeded", help please~


  • 0
    B
    #define _(X) (X<'G'?X>'A':2|(X>'G'))
    
    char** findRepeatedDnaSequences(char* s, int* returnSize) {
    char *p,**r,l[1048576] = { 0 };
    int n = 0, i, x, Z = (1 << 20) - 1, len;
    if ((len = strlen(s)) < 11) goto end;
    r = (char**)malloc(sizeof(char*)*len>>1);
    for (x = i = 0; i < 10; i++) x = (x << 2) | _(s[i]);
    for (p = s + 10; *p;p++){
    	if (!l[x]) l[x]++;
    	else if (l[x] > 0){
    		r[n] = (char*)malloc(sizeof(char)*11);
    		for (i = 0; i < 10; i++) r[n][i] = i[p - 10];
    		r[n++][10] = '\0';
    		l[x] = -1;
    	}
    	x = ((x << 2) | _(*p))&Z;
    }
    

    end:;
    *returnSize = n;
    return r;
    }


  • 0

    Please try submitting again, I have removed the memory limit on the judge side.


  • 0
    B

    Thanks! I have got the AC


Log in to reply
 

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