Int find[256] = {0} VS int *find = new int[256] {0}


  • 0
    W

    I use dynamic array to store the ascii idx of string T char members, but get some errors on leedcode submission. However my VS2013 proves me my answer is correct.

    when init a dynamic array:

    int find[256] = {0}; // Will be accepted

    int *find = new int[256] {0}; // Will fail in case 259: 259 / 266 test cases passed

    Why is that?

    Besides, why the array length has to be over 256? In ascii the last letter 'z' is 122 in Dec, right?


  • 1
    C

    I think the reason may be that g++ 4.7.3 (which is used by leetcode) doesn't fully support C++11 features. (Just a hint, I haven't investigated into this)


  • 0
    S

    Can you remind us what case 259 is?


Log in to reply
 

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