Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/neetcode-gh/leetcode
/ swap
Function
swap
javascript/0287-find-the-duplicate-number.js:152–152 ·
view source on GitHub ↗
(arr, a, b)
Source
from the content-addressed store, hash-verified
150
151
const
cyclicSort = (nums, index = 0) => {
152
const
swap = (arr, a, b) => ([arr[a], arr[b]] = [arr[b], arr[a]]);
153
154
while
(index < nums.length) {
155
/* Time O(N) */
Callers
2
cyclicSort
Function · 0.70
findDuplicate
Function · 0.70
Calls
no outgoing calls
Tested by
no test coverage detected