MCPcopy Create free account
hub / github.com/neetcode-gh/leetcode / searchDescending

Function searchDescending

javascript/0853-car-fleet.js:78–89  ·  view source on GitHub ↗
(coordinates, previous = 0, fleets = 0)

Source from the content-addressed store, hash-verified

76 ); /* Time O(N) | Space O(N) */
77
78var searchDescending = (coordinates, previous = 0, fleets = 0) => {
79 for (const coordinate of coordinates) {
80 /* Time O(N) */
81 const isPreviousLess = previous < coordinate;
82 if (!isPreviousLess) continue;
83
84 previous = coordinate;
85 fleets++;
86 }
87
88 return fleets;
89};

Callers 1

carFleetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected