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

Programming Exercises

Write a Kotlin program to perform matrix multiplication.

Medium

Problem Statement

Write a Kotlin program to perform matrix multiplication.

Sample Input

Matrix A = [[1, 2], [3, 4]], Matrix B = [[5, 6], [7, 8]]

Sample Output

19 22
43 50

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
fun multiplyMatrices(a: Array<Array<Int>>, b: Array<Array<Int>>): Array<Array<Int>> { // Add your code here to multiply the matrices } fun main() { val a = arrayOf(arrayOf(1, 2), arrayOf(3, 4)) val b = arrayOf(arrayOf(5, 6), arrayOf(7, 8)) val result = multiplyMatrices(a, b) result.forEach { println(it.joinToString(" ")) } }
Log in or sign up to run or submit your code.Log inSign up
Input
Matrix A = [[1, 2], [3, 4]], Matrix B = [[5, 6], [7, 8]]
Expected Output
19 22
43 50