forked from DaleStudy/leetcode-study
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjdalma.kt
More file actions
35 lines (29 loc) ยท 831 Bytes
/
jdalma.kt
File metadata and controls
35 lines (29 loc) ยท 831 Bytes
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
package leetcode_study
import io.kotest.matchers.shouldBe
import org.junit.jupiter.api.Test
class `same-tree` {
fun isSameTree(p: TreeNode?, q: TreeNode?): Boolean {
return if (p == null && q == null) {
true
} else if (p == null || q == null || p.`val` != q.`val`) {
false
} else {
isSameTree(p.left, q.left) && isSameTree(p.right, q.right)
}
}
@Test
fun `๋ ๊ฐ์ ํธ๋ฆฌ์ ๋๋ฑ์ฑ์ ๋ฐํํ๋ค`() {
isSameTree(
TreeNode.of(1,1,2),
TreeNode.of(1,1,2)
) shouldBe true
isSameTree(
TreeNode.of(1,1,2),
TreeNode.of(1,1,2,3)
) shouldBe false
isSameTree(
TreeNode.of(1,1,2),
TreeNode.of(1,1,3)
) shouldBe false
}
}