-
Notifications
You must be signed in to change notification settings - Fork 0
/
flipkart2
61 lines (36 loc) · 836 Bytes
/
flipkart2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Hi Dheeraj, Deepak here ...
item, deadline, penalty
i1, 1, 100
i2, 2, 100
i3, 2, 200
(sorting on penalty example)
item, deadline, penalty
i1, 1, 100
i2, 2, 50
i3, 2, 200
(sorting on deadline then on penalty)
item, deadline, penalty
i1, 1, 100
i2, 2, 200
i3, 2, 200
10
/ \
5
/ \
1 2
(10(5(1()())2....
String getString(Node root){
StringBuilder sb = new StringBuilder();
Stack stack = new Stack();
stack.push(root);
while(!stack.isEmpty(){
Node node = stack.pop();
if(node == null){
sb.add("()");
}else{
sb.add("("+node.data);
stack.push(node.left);
stack.push(node.right);
}
}
}