Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/careercup/ctci
/ hasValidPrev
Method
hasValidPrev
java/Chapter 5/Question5_3/Question.java:39–47 ·
view source on GitHub ↗
(int i)
Source
from the content-addressed store, hash-verified
37
}
38
39
public
static
boolean hasValidPrev(
int
i) {
40
while
((i & 1) == 1) {
41
i >>= 1;
42
}
43
if
(i == 0) {
44
return
false;
45
}
46
return
true;
47
}
48
49
public
static
int
getNextSlow(
int
i) {
50
if
(!hasValidNext(i)) {
Callers
1
getPrevSlow
Method · 0.95
Calls
no outgoing calls
Tested by
no test coverage detected