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 d4d1840 commit 1602133Copy full SHA for 1602133
oh-chaeyeon/5주차_트리/Same_Tree.js
@@ -0,0 +1,28 @@
1
+/**
2
+ * Definition for a binary tree node.
3
+ * function TreeNode(val, left, right) {
4
+ * this.val = (val===undefined ? 0 : val)
5
+ * this.left = (left===undefined ? null : left)
6
+ * this.right = (right===undefined ? null : right)
7
+ * }
8
+ */
9
10
+ * @param {TreeNode} p
11
+ * @param {TreeNode} q
12
+ * @return {boolean}
13
14
+var isSameTree = function (p, q) {
15
+ if (p === null && q === null) {
16
+ return true;
17
+ }
18
+
19
+ if (p === null || q === null) {
20
+ return false;
21
22
23
+ if (p.val !== q.val) {
24
25
26
27
+ return isSameTree(p.left, q.left) && isSameTree(p.right, q.right);
28
+};
0 commit comments