FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
leetcode-study/missing-number/higeuni.js at main · DaleStudy/leetcode-study · GitHub
DaleStudy
/
leetcode-study
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
359
Star
156
Code
Issues
75
Pull requests
5
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
leetcode-study
/
missing-number
/
higeuni.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
15 lines (13 loc) · 313 Bytes
Breadcrumbs
leetcode-study
/
missing-number
/
higeuni.js
Copy path
File metadata and controls
15 lines (13 loc) · 313 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
*
@param
{
number[]
} nums
*
@return
{
number
}
*
* complexity
* time: O(n)
* space: O(1)
*/
var
missingNumber
=
function
(
nums
)
{
const
sumOfNums
=
nums
.
reduce
(
(
acc
,
curr
)
=>
acc
+
curr
,
0
)
;
const
sumOfTotalNumbers
=
(
nums
.
length
*
(
nums
.
length
+
1
)
)
/
2
;
return
sumOfTotalNumbers
-
sumOfNums
;
}
;
Back
|
FazBrowse Home
|
New Git URL