DON'T USE * in your code.


  • 0
    R

    I see many people forgetting about multiplication symbol.

    Two common mistakes.
    change

     a *= -1;
    

    to

     a = -a;
    

    change

    res = res * symbol;
    

    to

    res = (symbol == -1)? res = -res: res;
    

    or (make symbol into boolean)

    res = (neg)? res = -res: res;

Log in to reply
 

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