We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a91ffb5 commit 256fbbfCopy full SHA for 256fbbf
scripts/algorithms/M/Missing Number/Missing Number.js
@@ -1,11 +1,3 @@
1
-// Runtime: 90 ms (Top 77.79%) | Memory: 44.2 MB (Top 70.06%)
2
var missingNumber = function(nums) {
3
- // Initialize res as zero...
4
- let res = 0;
5
- // Traverse all the element through the loop...
6
- for (let i = 0; i < nums.length; ++i) {
7
- // Calculation process by helping of Bit Manipulation...
8
- res ^= nums[i] ^ (i + 1);
9
- }
10
- return res; // Return the result
+ return ((1 + nums.length)*nums.length/2) - nums.reduce((a,b) => a+b)
11
};
0 commit comments