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/problems/make-array-zero-by-subtracting-equal-amounts/
解题思路:
输入:nums = [1,5,0,3,5] 输出:3 解释: 第一步操作:选出 x = 1 ,之后 nums = [0,4,0,2,4] 。 第二步操作:选出 x = 2 ,之后 nums = [0,2,0,0,2] 。 第三步操作:选出 x = 2 ,之后 nums = [0,0,0,0,0] 。
1
3
5
nums
Set
/** * @param {number[]} nums * @return {number} */ var minimumOperations = function (nums) { let set = new Set() for (const num of nums) { // 每个非零数字都只会减一次,因此只需要用Set统计即可 num > 0 && set.add(num) } return set.size }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
原题链接:
https://leetcode.cn/problems/make-array-zero-by-subtracting-equal-amounts/
解题思路:
1
、3
、5
,无论个数多少都只做了一次减法nums
中一共有多少种非零数字Set
统计The text was updated successfully, but these errors were encountered: