1-Line JavaScript Code Solution


  • 0
    Z

    /**

    • @param {number} num
    • @return {string}
      */
      var toHex = function(num) {
      return num >= 0 ? num.toString(16) : (4294967296 + num).toString(16);
      };

  • 0
    L

    u can use this:
    return (num>>>0).toString(16);
    but I think it's cheat using toString(16);


Log in to reply
 

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