Skip to content

Commit 63f9c65

Browse files
committed
修正代码格式
1 parent 44bfe58 commit 63f9c65

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

docs/0000-01-sliding-window.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ LeetCode 1074. Number of Submatrices That Sum to Target (hard)
6868
int left = 0, right = 0;
6969
7070
while (right < s.size()) {
71-
window.add(s[right]);
72-
right++;
71+
window.add(s[right]);
72+
right++;
7373
7474
while (valid) {
7575
window.remove(s[left]);
@@ -93,4 +93,4 @@ right++;
9393

9494
. https://leetcode-cn.com/problems/find-all-anagrams-in-a-string/solution/hua-dong-chuang-kou-tong-yong-si-xiang-jie-jue-zi-/[滑动窗口通用思想解决子串问题 - 找到字符串中所有字母异位词 - 力扣(LeetCode)]
9595
. https://leetcode-cn.com/problems/find-all-anagrams-in-a-string/solution/javayou-hua-labuladongda-lao-hua-dong-chuang-kou-t/[Java优化labuladong大佬滑动窗口通用方法 - 找到字符串中所有字母异位词 - 力扣(LeetCode)]
96-
. https://mp.weixin.qq.com/s/6YeZUCYj5ft-OGa85sQegw[面试官,你再问我滑动窗口问题试试?我有解题模板,不怕!]
96+
. https://mp.weixin.qq.com/s/6YeZUCYj5ft-OGa85sQegw[面试官,你再问我滑动窗口问题试试?我有解题模板,不怕!]

src/main/java/com/diguage/algorithm/util/TreeNodeUtils.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
import com.fasterxml.jackson.core.JsonProcessingException;
44
import com.fasterxml.jackson.databind.ObjectMapper;
55

6-
import java.util.ArrayList;
7-
import java.util.Arrays;
8-
import java.util.List;
9-
import java.util.Objects;
6+
import java.util.*;
107

118
/**
129
* @author D瓜哥, https://www.diguage.com/
@@ -41,6 +38,24 @@ public static TreeNode buildTree(List<Integer> array) {
4138
return result;
4239
}
4340

41+
public List<Integer> printTree(TreeNode root) {
42+
if (Objects.isNull(root)) {
43+
return Collections.emptyList();
44+
}
45+
List<Integer> result = new ArrayList<>();
46+
Deque<TreeNode> stack = new LinkedList<>();
47+
stack.offer(root);
48+
int level = 1;
49+
while (!stack.isEmpty()) {
50+
int size = stack.size();
51+
for (int i = 0; i < size; i++) {
52+
TreeNode node = stack.poll();
53+
}
54+
}
55+
56+
return result;
57+
}
58+
4459
public static void main(String[] args) throws JsonProcessingException {
4560
ObjectMapper mapper = new ObjectMapper();
4661
List<Integer> integers = Arrays.asList(1, 2, 2, 3, 4, 4, 3);

0 commit comments

Comments
 (0)