4
4
5
5
public class Solution {
6
6
private static final int MX_LN = 61 ;
7
- private static final long [][] SLCT = new long [MX_LN ][MX_LN ];
8
- private static final int [] POP_HGHT = new int [MX_LN ];
9
- private static boolean strt = false ;
7
+ private final long [][] slct = new long [MX_LN ][MX_LN ];
8
+ private final int [] popHeight = new int [MX_LN ];
9
+ private boolean strt = false ;
10
10
11
11
private void setup () {
12
12
if (strt ) {
13
13
return ;
14
14
}
15
15
for (int i = 0 ; i < MX_LN ; i ++) {
16
- SLCT [i ][0 ] = SLCT [i ][i ] = 1 ;
16
+ slct [i ][0 ] = slct [i ][i ] = 1 ;
17
17
for (int j = 1 ; j < i ; j ++) {
18
- SLCT [i ][j ] = SLCT [i - 1 ][j - 1 ] + SLCT [i - 1 ][j ];
18
+ slct [i ][j ] = slct [i - 1 ][j - 1 ] + slct [i - 1 ][j ];
19
19
}
20
20
}
21
- POP_HGHT [1 ] = 0 ;
21
+ popHeight [1 ] = 0 ;
22
22
for (int v = 2 ; v < MX_LN ; v ++) {
23
- POP_HGHT [v ] = 1 + POP_HGHT [Long .bitCount (v )];
23
+ popHeight [v ] = 1 + popHeight [Long .bitCount (v )];
24
24
}
25
25
strt = true ;
26
26
}
@@ -38,7 +38,7 @@ private long countNumbers(long upperLimit, int setBits) {
38
38
for (int pos = len - 1 ; pos >= 0 ; pos --) {
39
39
if (((upperLimit >> pos ) & 1 ) == 1 ) {
40
40
if (setBits - used <= pos ) {
41
- count += SLCT [pos ][setBits - used ];
41
+ count += slct [pos ][setBits - used ];
42
42
}
43
43
used ++;
44
44
if (used > setBits ) {
@@ -59,7 +59,7 @@ public long popcountDepth(long tillNumber, int depthQuery) {
59
59
}
60
60
long total = 0 ;
61
61
for (int ones = 1 ; ones < MX_LN ; ones ++) {
62
- if (POP_HGHT [ones ] == depthQuery - 1 ) {
62
+ if (popHeight [ones ] == depthQuery - 1 ) {
63
63
total += countNumbers (tillNumber , ones );
64
64
}
65
65
}
0 commit comments