Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdd52268

Browse files
add a test for 270
1 parentd185eca commitdd52268

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.fishercoder;
2+
3+
import com.fishercoder.common.classes.TreeNode;
4+
import com.fishercoder.common.utils.TreeUtils;
5+
import com.fishercoder.solutions._270;
6+
import org.junit.BeforeClass;
7+
import org.junit.Test;
8+
9+
import java.util.Arrays;
10+
11+
import static junit.framework.Assert.assertEquals;
12+
13+
public class _270Test {
14+
private static _270.Solution1 solution1;
15+
private static int expected;
16+
private static TreeNode root;
17+
private static double target;
18+
19+
@BeforeClass
20+
public static void setup() {
21+
solution1 = new _270.Solution1();
22+
}
23+
24+
@Test
25+
public void test1() {
26+
root = TreeUtils.constructBinaryTree(Arrays.asList(4, 2, 5, 1, 3));
27+
expected = 4;
28+
target = 3.714286;
29+
assertEquals(expected, solution1.closestValue(root, target));
30+
}
31+
32+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp