Derived missing OJ test cases when M*(M+1)/2 == T and M, T are different in odd/even


  • 0

    To @administrators
    There is an early termination case for this problem:

    • if (maxChosibleInteger*(maxChosibleInteger+1)/2 == desiredTotal) return maxChosibleInteger%2;,

    which means if the sum of all values from initial pool happens to be desiredTotal, then apparently, the order to pick numbers is irrelevant to the outcome of the game. It is just whoever picks in the last value from the pool reaches desiredTotal. So the first player wins iff there is odd count of values initial in the pool.

    However, when I tested return desiredTotal%2 instead of the correct return maxChosibleInteger%2 in the condition above, OJ still accepted the code, which means OJ does not include such test cases when the condition is true, .

    Therefore, I suggest to add the following two test cases, where the sum condition holds and maxChosibleInteger and desiredTotal are different under %2:

    • maxChosibleInteger = 19, desiredTotal = 190;
    • maxChosibleInteger = 18, desiredTotal = 171;

  • 0

    @zzg_zzm Thanks! I have just added your test cases.


  • 0

    @1337c0d3r said in Derived missing OJ test cases when M*(M+1)/2 == T and M, T are different in odd/even:

    @zzg_zzm Thanks! I have just added your test cases.

    Just tested. Thank you so much !!!


Log in to reply
 

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