We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原题链接:https://leetcode-cn.com/problems/plus-one/
解题思路:
/** * @param {number[]} digits * @return {number[]} */ var plusOne = function(digits) { const numStr = digits.join('') // 将数组转换为字符串 const bigInt = BigInt(numStr) // 将字符串转换为BigInt类型 const result = bigInt + 1n // 加1,一个整数字面量后面加 n 的方式定义一个 BigInt const resultStr = new String(result) // 将数字转换为字符串 const resultStrArr = resultStr.split('') // 将字符串转换为数组 const resultNumArr = resultStrArr.map(num => Number(num)) // 将字符串数组转换成数字数组 return resultNumArr // 返回结果 };
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原题链接:https://leetcode-cn.com/problems/plus-one/
解题思路:
The text was updated successfully, but these errors were encountered: