We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef44f97 commit 8b7eb5fCopy full SHA for 8b7eb5f
NODES WITHOUT SIBLINGS.txt
@@ -0,0 +1,33 @@
1
+public class Solution {
2
+
3
+ public static void printNodesWithoutSibling(BinaryTreeNode<Integer> root) {
4
+ //Your code goes here
5
+ if (root==null)
6
+ {
7
+ return;
8
+ }
9
10
+ if (root.left==null && root.right==null)
11
12
13
14
15
+ if (root.left==null)
16
17
+ System.out.print(root.right.data+" ");
18
+ printNodesWithoutSibling(root.right);
19
20
+ else if (root.right==null)
21
22
+ System.out.print(root.left.data+" ");
23
+ printNodesWithoutSibling(root.left);
24
25
26
+ else
27
28
29
30
31
32
33
+}
0 commit comments