Create a program to find the intersection of two arrays.
MediumProblem Statement
Create a program to find the intersection of two arrays.
Sample Input
Two arrays: [1, 2, 3, 4] and [3, 4, 5, 6]
Sample Output
Intersection: [3, 4]
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
fun findIntersection(arr1: Array<Int>, arr2: Array<Int>): List<Int> {
// Add your code here to find the intersection
}
fun main() {
val arr1 = arrayOf(1, 2, 3, 4)
val arr2 = arrayOf(3, 4, 5, 6)
println("Intersection: ${findIntersection(arr1, arr2)}")
}
Input
Two arrays: [1, 2, 3, 4] and [3, 4, 5, 6]
Expected Output
Intersection: [3, 4]