Code
Hub
Workspaces
Connect
Indexed graphs
Engine
MCP
copy
hub
/
github.com/qiyuangong/leetcode
/ binaryGap
Method
binaryGap
java/868_Binary_Gap.java:16–26 ·
view source on GitHub ↗
(int N)
Source
from the content-addressed store, hash-verified
14
}*/
15
16
public
int
binaryGap(
int
N) {
17
int
last = -1, ans = 0;
18
for
(
int
i = 0; i < 32; ++i)
19
if
(((N >> i) & 1) > 0) {
20
// Store max
21
if
(last >= 0)
22
ans = Math.max(ans, i - last);
23
last = i;
24
}
25
return
ans;
26
}
27
}
Callers
nothing calls this directly
Calls
1
max
Method · 0.80
Tested by
no test coverage detected