(int i)
| 18 | } |
| 19 | |
| 20 | public static boolean hasValidNext(int i) { |
| 21 | if (i == 0) { |
| 22 | return false; |
| 23 | } |
| 24 | int count = 0; |
| 25 | while ((i & 1) == 0) { |
| 26 | i >>= 1; |
| 27 | count++; |
| 28 | } |
| 29 | while ((i & 1) == 1) { |
| 30 | i >>= 1; |
| 31 | count++; |
| 32 | } |
| 33 | if (count == 31) { |
| 34 | return false; |
| 35 | } |
| 36 | return true; |
| 37 | } |
| 38 | |
| 39 | public static boolean hasValidPrev(int i) { |
| 40 | while ((i & 1) == 1) { |