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

Function calcMaxBit

javascript/0287-find-the-duplicate-number.js:78–88  ·  view source on GitHub ↗
(nums, bits = 0)

Source from the content-addressed store, hash-verified

76};
77
78const calcMaxBit = (nums, bits = 0) => {
79 let max = Math.max(0, ...nums); /* Time O(N) */
80
81 while (max) {
82 /* Time O(log(MAX)) */
83 max >>= 1;
84 bits++;
85 }
86
87 return bits;
88};
89
90const count = (nums, bit) => {
91 let [baseCount, numsCount, mask] = [0, 0, 1 << bit];

Callers 1

findDuplicateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected