Skip to content

Commit 99357ba

Browse files
committed
add leetcode: offer-17
1 parent 718e62a commit 99357ba

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Algorithm/src/acwing/basic/chapter2/_143MaximumXORPair.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class _143MaximumXORPair {
3232
public static int N = 100010;
3333
// trie树的最大结点数:最多有10w个数,每个数最多有31位的长度,一个结点只能表示一位
3434
public static int M = 3000000;
35-
// son是Trie树,第一维表示结点数;第二维是结点的类型,记录该位0还是1。数组值表示其在trie树中第几个的索引结点
35+
// son是Trie树,(下标)第一维表示结点数;第二维是结点的类型,记录该位0还是1。数组值表示其在trie树中第几个的索引结点
3636
public static int[][] son = new int[M][2];
3737
// trie的当前指针,0是根结点
3838
public static int idx = 0;
@@ -77,7 +77,7 @@ public static void insert(int x) {
7777
// for走完,一个数的二进制位在trie中就构建完成
7878
}
7979

80-
80+
// 查询x对应的在trie数中存在的最大异或对
8181
public static int query(int x) {
8282
// res记录当前数x的最大异或对是几。p遍历指针
8383
int res = 0, p = 0;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package offer;
2+
3+
/**
4+
* @author : CodeWater
5+
* @create :2022-07-25-12:53
6+
* @Function Description :17. 打印从1到最大的n位数
7+
*/
8+
public class _17PrintFrom1ToTheLargestNDigits {
9+
class Solution {
10+
public int[] printNumbers(int n) {
11+
int end = (int)Math.pow( 10 , n ) - 1;
12+
int[] res = new int[end];
13+
for( int i = 1 ; i <= end ; i++ ){
14+
res[i - 1] = i;
15+
}
16+
return res;
17+
}
18+
}
19+
}

0 commit comments

Comments
 (0)