classSolution{public:vector<vector<int>>zigzagLevelOrder(TreeNode*root){vector<vector<int>>ret;queue<TreeNode*>current,next;//利用两个队列的交替来区分每一层boolisRe=false;vector<int>v;if(root==NULL)returnret;current.push(r
6. ZigZag Conversion # 题目 # The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by
31. Next Permutation # 题目 # Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted i
level-order binary tree level order traversal: BFS using queue. Can use queue.size instead of two queues. binary tree level order traversal II: BFS using queue. binary tree zig-zag level order traversal: BFS using stack. populating next right pointers in each node II and II: very special...
public ArrayList<Integer> inorderTraversal(TreeNode root) { ArrayList<Integer> result = new ArrayList<Integer>(); Stack<TreeNode> stack = new Stack<TreeNode>(); TreeNode curr = root; while (!stack.isEmpty() || curr != null) {
106.construct-binary-tree-from-inorder-and-postorder-traversal.cpp 107.binary-tree-level-order-traversal-ii.cpp 1072.flip-columns-for-maximum-number-of-equal-rows.cpp 1074.number-of-submatrices-that-sum-to-target.cpp 108.convert-sorted-array-to-binary-search-tree.cpp 109.convert-sorted-...
0094. Binary Tree Inorder Traversal 0095. Unique Binary Search Trees I I 0096. Unique Binary Search Trees 0097. Interleaving String 0098. Validate Binary Search Tree 0099. Recover Binary Search Tree 0100~0199 0200~0299 0300~0399 0400~0499 0500~0599 0600~0699 0700~0799 0800~0899 0900~0999 100...
40. Combination Sum II # 题目 # Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. Each number in candidates may only be used once in
[0429][N-ary Tree Level Order Traversal] commit Jul 3, 2019 [0434][Number of Segments in a String] commit Jul 10, 2019 [0437][Path Sum III] commit Jul 3, 2019 [0438][Find All Anagrams in a String] commit Jul 9, 2019 [0442][Find All Duplicates in an Array] commit Jul 11, 20...
[0429][N-ary Tree Level Order Traversal] commit Jul 3, 2019 [0434][Number of Segments in a String] commit Jul 10, 2019 [0437][Path Sum III] commit Jul 3, 2019 [0438][Find All Anagrams in a String] commit Jul 9, 2019 [0442][Find All Duplicates in an Array] commit Jul 11, 20...