0ms C solution simple code


  • -6
    S

    int rob(int* nums, int numsSize) {

    int included,excluded,a,i;
    included=nums[0];
    excluded=0;
    for(i=1;i<numsSize;i++)
    {a=included;
    included=nums[i]+excluded;
    excluded= a>excluded? a: excluded;
    }
    return included>excluded? included : excluded;
    }


Log in to reply
 

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