Submission Detail

60 / 60 test cases passed.
Status:

Accepted

Runtime: 1 ms
Memory Usage: 40.4 MB
Submitted: 0 minutes ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

Sorry. We do not have enough accepted submissions to show distribution chart.

Accepted Solutions Memory Distribution

39200
39300
39400
39500
39600
39700
39800
39900
40000
40100
40200
40300
40400
40500
5
10
15
java
You are here!
Your memory usage beats 28.86 % of java submissions.
Memory (KB)
Distribution (%)

39200
39300
39400
39500
39600
39700
39800
39900
40000
40100
40200
40300
40400
40500
5
10
15
Zoom area by dragging across this chart

Invite friends to challenge Same Tree


Submitted Code: 0 minutes ago

Language: java

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
/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode() {}
* TreeNode(int val) { this.val = val; }
* TreeNode(int val, TreeNode left, TreeNode right) {
* this.val = val;
* this.left = left;
* this.right = right;
* }
* }
*/
class Solution {
public boolean isSameTree(TreeNode p, TreeNode q) {
ArrayList<String> p_trav = new ArrayList<>();
ArrayList<String> q_trav = new ArrayList<>();
p_trav = iot(p,p_trav,"Ro");
q_trav = iot(q,q_trav,"Ro");
if (p_trav.equals(q_trav))
return true;
else
return false;
}
public ArrayList<String> iot(TreeNode root,ArrayList<String> trav, String pos) {
if (root != null) {
trav = iot(root.left,trav,"L");
String value = Integer.toString(root.val) + pos;
trav.add(value);
trav = iot(root.right,trav,"R");
}
return trav;
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX