Simple 4ms solution in C


  • 0
    B
    bool canJump(int* nums, int numsSize) {
    	int *p, *q, *end;
    	end = nums + numsSize - 1;
    	for (p = nums; p < end; p++){
    		if (!*p){
    			for (q = nums; q < p; q++)
    				if (*q + q > p)
    					goto ctn;
    			return false;
    		}
    	ctn:;
    	}
    	return true;
    }

Log in to reply
 

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