MCPcopy Create free account
hub / github.com/careercup/ctci / getPrevSlow

Method getPrevSlow

java/Chapter 5/Question5_3/Question.java:61–71  ·  view source on GitHub ↗
(int i)

Source from the content-addressed store, hash-verified

59 }
60
61 public static int getPrevSlow(int i) {
62 if (!hasValidPrev(i)) {
63 return -1;
64 }
65 int num_ones = countOnes(i);
66 i--;
67 while (countOnes(i) != num_ones) {
68 i--;
69 }
70 return i;
71 }
72
73 public static int getNext(int n) {
74 int c = n;

Callers 1

mainMethod · 0.95

Calls 2

hasValidPrevMethod · 0.95
countOnesMethod · 0.95

Tested by

no test coverage detected