-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(arrays): intersection of arrays
- Loading branch information
1 parent
a68c11a
commit 350f603
Showing
6 changed files
with
60 additions
and
60 deletions.
There are no files selected for viewing
File renamed without changes.
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
24 changes: 24 additions & 0 deletions
24
...c/test/kotlin/com/kotlinground/algorithms/arrays/intersection/IntersectionOfArraysTest.kt
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,24 @@ | ||
package com.kotlinground.algorithms.arrays.intersection | ||
|
||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertContentEquals | ||
|
||
class IntersectionOfArraysTest { | ||
|
||
@Test | ||
fun `Should return (2) for nums1=(1,2,2,1) and nums2=(2,2)`() { | ||
val nums1 = arrayOf(1, 2, 2, 1) | ||
val nums2 = arrayOf(2, 2) | ||
val expected = listOf(2) | ||
assertContentEquals(expected, intersectionOne(nums1, nums2)) | ||
} | ||
|
||
@Test | ||
fun `Should return (9,4) for nums1=(4,9,5) and nums2=(9,4,9,8,4)`() { | ||
val nums1 = arrayOf(4, 9, 5) | ||
val nums2 = arrayOf(9, 4, 9, 8, 4) | ||
val expected = listOf(9, 4) | ||
assertContentEquals(expected, intersectionOne(nums1, nums2)) | ||
} | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
...est/kotlin/com/kotlinground/algorithms/arrays/intersection/IntersectionTwoOfArraysTest.kt
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,24 @@ | ||
package com.kotlinground.algorithms.arrays.intersection | ||
|
||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertContentEquals | ||
|
||
class IntersectionTwoOfArraysTest { | ||
|
||
@Test | ||
fun `Should return (2,2) for nums1=(1,2,2,1) and nums2=(2,2)`() { | ||
val nums1 = arrayOf(1, 2, 2, 1) | ||
val nums2 = arrayOf(2, 2) | ||
val expected = listOf(2, 2) | ||
assertContentEquals(expected, intersectionTwo(nums1, nums2)) | ||
} | ||
|
||
@Test | ||
fun `Should return (9,4) or (4, 9) for nums1=(4,9,5) and nums2=(9,4,9,8,4)`() { | ||
val nums1 = arrayOf(4, 9, 5) | ||
val nums2 = arrayOf(9, 4, 9, 8, 4) | ||
val expected = listOf(9, 4) | ||
assertContentEquals(expected, intersectionTwo(nums1, nums2)) | ||
} | ||
|
||
} |
24 changes: 0 additions & 24 deletions
24
...n/com/kotlinground/datastructures/arrays/intersectionofarrays/IntersectionOfArraysTest.kt
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
...om/kotlinground/datastructures/arrays/intersectionofarrays/IntersectionTwoOfArraysTest.kt
This file was deleted.
Oops, something went wrong.