File tree 1 file changed +0
-32
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +0
-32
lines changed Original file line number Diff line number Diff line change 6
6
import java .util .Set ;
7
7
import java .util .TreeSet ;
8
8
9
- /**
10
- * 671. Second Minimum Node In a Binary Tree
11
- *
12
- * Given a non-empty special binary tree consisting of nodes with the non-negative value,
13
- * where each node in this tree has exactly two or zero sub-node.
14
- * If the node has two sub-nodes, then this node's value is the smaller value among its two sub-nodes.
15
- * Given such a binary tree, you need to output the second minimum value in the set made of all the nodes' value in the whole tree.
16
- * If no such second minimum value exists, output -1 instead.
17
-
18
- Example 1:
19
-
20
- Input:
21
- 2
22
- / \
23
- 2 5
24
- / \
25
- 5 7
26
-
27
- Output: 5
28
- Explanation: The smallest value is 2, the second smallest value is 5.
29
-
30
- Example 2:
31
-
32
- Input:
33
- 2
34
- / \
35
- 2 2
36
-
37
- Output: -1
38
- Explanation: The smallest value is 2, but there isn't any second smallest value.
39
-
40
- */
41
9
public class _671 {
42
10
public static class Solution1 {
43
11
public int findSecondMinimumValue (TreeNode root ) {
You can’t perform that action at this time.
0 commit comments