the Precision Problem of 1-Line JavaScript Code


  • 0
    Z

    /**

    • @param {number[]} digits
    • @return {number[]}
      */
      var plusOne = function(digits) {
      return (digits.reduce((a, b) => (a * 10 + b)) + 1).toString().split('').map(Number);
      };
      eg.
      Input: [6,1,4,5,3,9,0,1,9,5,1,8,6,7,0,5,5,4,3],
      Output: [6,1,4,5,3,9,0,1,9,5,1,8,6,7,0,6,0,0,0]

  • 0
    Z

    -2^53~2^53: -9 007 199 254 740 992 ~ 9 007 199 254 740 992


Log in to reply
 

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