Skip to content

Commit e8cb699

Browse files
[LEET-0000] add problem descriptions
1 parent 4842b86 commit e8cb699

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

leetcode-algorithms/src/main/java/com/stevesun/solutions/BinaryTreeLevelOrderTraversal.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
]
3030
*/
3131
public class BinaryTreeLevelOrderTraversal {
32-
//Cheers, easily made it AC'ed on the first submission now, practice does make perfect!
3332
public List<List<Integer>> levelOrder(TreeNode root) {
3433
List<List<Integer>> result = new ArrayList<List<Integer>>();
3534
if(root == null) return result;

leetcode-algorithms/src/main/java/com/stevesun/solutions/BinaryTreePostOrderTraversal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
Note: Recursive solution is trivial, could you do it iteratively?*/
2323

2424
public class BinaryTreePostOrderTraversal {
25-
/**modify the code for pre-order traversal so that it becomes root->right->left, and then reverse the result to get left->right->root, so tricky!!!*/
25+
/**A tricky one: Modify the code for pre-order traversal so that it becomes root->right->left, and then reverse the result to get left->right->root.*/
2626
public static List<Integer> postorderTraversal_iterative(TreeNode root) {
2727
List<Integer> result = new ArrayList();
2828
Stack<TreeNode> stack = new Stack();

leetcode-algorithms/src/main/java/com/stevesun/solutions/CountUnivalueSubtrees.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
import com.stevesun.common.classes.TreeNode;
44

5+
/**Given a binary tree, count the number of uni-value subtrees.
6+
7+
A Uni-value subtree means all nodes of the subtree have the same value.
8+
9+
For example:
10+
Given binary tree,
11+
5
12+
/ \
13+
1 5
14+
/ \ \
15+
5 5 5
16+
return 4.
17+
18+
*/
519
public class CountUnivalueSubtrees {
620

721
public int countUnivalSubtrees(TreeNode root) {

leetcode-algorithms/src/main/java/com/stevesun/solutions/TwoSumIIInputArrayIsSorted.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
import com.stevesun.common.utils.CommonUtils;
44

5+
/**
6+
* Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.
7+
8+
The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based.
9+
10+
You may assume that each input would have exactly one solution.
11+
12+
Input: numbers={2, 7, 11, 15}, target=9
13+
Output: index1=1, index2=2
14+
15+
*/
516
public class TwoSumIIInputArrayIsSorted {
617
public static int[] twoSum(int[] numbers, int target) {
718
int left = 0, right = numbers.length-1;

0 commit comments

Comments
 (0)