-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Top K Frequent Elements - Unit tests
- Loading branch information
Showing
2 changed files
with
47 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/test/java/io/dksifoua/leetcode/topkfrequentelements/SolutionTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.dksifoua.leetcode.topkfrequentelements; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertArrayEquals; | ||
|
||
public class SolutionTest { | ||
|
||
public final Solution solution = new Solution(); | ||
|
||
@Test | ||
void test1() { | ||
int[] nums = { 1, 1, 1, 2, 2, 3 }; | ||
int k = 2; | ||
int[] result = solution.topKFrequent(nums, k); | ||
Arrays.sort(result); | ||
assertArrayEquals(new int[] { 1, 2 }, result); | ||
} | ||
|
||
@Test | ||
void test2() { | ||
int[] nums = { 1 }; | ||
int k = 1; | ||
int[] result = solution.topKFrequent(nums, k); | ||
Arrays.sort(result); | ||
assertArrayEquals(new int[] { 1 }, result); | ||
} | ||
} |