Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to find the intersection of three arrays.

Hard

Problem Statement

Write a function to find the intersection of three arrays.

Sample Input

Write a function to find the intersection of three arrays.

Sample Output

Intersection: [3]

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun intersection(arr1: Array<Int>, arr2: Array<Int>, arr3: Array<Int>): List<Int> { return arr1.filter { it in arr2 && it in arr3 } } fun main() { val arr1 = arrayOf(1, 2, 3) val arr2 = arrayOf(2, 3, 4) val arr3 = arrayOf(3, 4, 5) println("Intersection: ${intersection(arr1, arr2, arr3)}") }
Log in or sign up to run or submit your code.Log inSign up
Input
Write a function to find the intersection of three arrays.
Expected Output
Intersection: [3]