MCPcopy 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
151const 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

cyclicSortFunction · 0.70
findDuplicateFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected