Skip to content

Commit adb91b1

Browse files
add problem descriptions
1 parent 3002779 commit adb91b1

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

EASY/src/easy/BinaryTreePaths.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
package easy;
22

3+
import classes.TreeNode;
4+
import utils.CommonUtils;
5+
36
import java.util.ArrayList;
47
import java.util.List;
58

6-
import utils.CommonUtils;
7-
import classes.TreeNode;
8-
9-
/**257. Binary Tree Paths Question Editorial Solution My Submissions
10-
Total Accepted: 59117
11-
Total Submissions: 191659
12-
Difficulty: Easy
9+
/**257. Binary Tree Paths
10+
*
1311
Given a binary tree, return all root-to-leaf paths.
1412
1513
For example, given the following binary tree:

EASY/src/easy/BullsandCows.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
package easy;
22

3-
import java.util.HashSet;
4-
import java.util.Set;
3+
/**You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your secret number exactly in both digit and position (called "bulls") and how many digits match the secret number but locate in the wrong position (called "cows"). Your friend will use successive guesses and hints to eventually derive the secret number.
54
5+
For example:
6+
7+
Secret number: "1807"
8+
Friend's guess: "7810"
9+
Hint: 1 bull and 3 cows. (The bull is 8, the cows are 0, 1 and 7.)
10+
Write a function to return a hint according to the secret number and friend's guess, use A to indicate the bulls and B to indicate the cows. In the above example, your function should return "1A3B".
11+
12+
Please note that both secret number and friend's guess may contain duplicate digits, for example:
13+
14+
Secret number: "1123"
15+
Friend's guess: "0111"
16+
In this case, the 1st 1 in friend's guess is a bull, the 2nd or 3rd 1 is a cow, and your function should return "1A1B".
17+
You may assume that the secret number and your friend's guess only contain digits, and their lengths are always equal.*/
618
public class BullsandCows {
719

820
public String getHint(String secret, String guess) {

EASY/src/easy/BinaryTreeZigzagLevelOrderTraversal.java renamed to MEDIUM/src/medium/BinaryTreeZigzagLevelOrderTraversal.java

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
package easy;
2-
3-
import java.util.ArrayList;
4-
import java.util.Collections;
5-
import java.util.LinkedList;
6-
import java.util.List;
7-
import java.util.Queue;
1+
package medium;
82

93
import classes.TreeNode;
104

5+
import java.util.*;
6+
117
/**
128
* 103. Binary Tree Zigzag Level Order Traversal
139
*

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
|111|[Minimum Depth of Binary Tree](https://leetcode.com/problems/minimum-depth-of-binary-tree/)|[Solution](../../blob/master/EASY/src/easy/MinimumDepthofBinaryTree.java)| O(n)|O(1)~O(h) | Easy| BFS, DFS
112112
|110|[Balanced Binary Tree](https://leetcode.com/problems/balanced-binary-tree/)|[Solution](../../blob/master/EASY/src/easy/BalancedBinaryTree.java)| O(n)|O(1)~O(h) | Easy| DFS
113113
|107|[Binary Tree Level Order Traversal II](https://leetcode.com/problems/binary-tree-level-order-traversal-ii/)|[Solution](../../blob/master/EASY/src/easy/BinaryTreeLevelOrderTraversalII.java)| O(nlogn)|O(h) | Easy| BFS
114+
|103|[Binary Tree Zigzag Level Order Traversal](https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/)|[Solution](../../blob/master/EASY/src/easy/BinaryTreeZigzagLevelOrderTraversal.java)| O(n)|O(h) | Medium| BFS,DFS
114115
|102|[Binary Tree Level Order Traversal](https://leetcode.com/problems/binary-tree-level-order-traversal/)|[Solution](../../blob/master/EASY/src/easy/BinaryTreeLevelOrderTraversal.java)| O(n)|O(h) | Easy| BFS
115116
|91|[Decode Ways](https://leetcode.com/problems/decode-ways/)|[Solution](../../blob/master/MEDIUM/src/medium/DecodeWays.java)| O(n)|O(n) | Medium| DP
116117
|98|[Validate Binary Search Tree](https://leetcode.com/problems/validate-binary-search-tree/)|[Solution] | O(n) | O(1) | Medium | DFS/Recursion

0 commit comments

Comments
 (0)