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

Programming Exercises

Write an R program to compute the inverse of a non-singular matrix without using the solve function.

Hard

Problem Statement

Write an R program to compute the inverse of a non-singular matrix without using the solve function.

Sample Input

Matrix: 
 [,1] [,2]
[1,] 4 7
[2,] 2 6

Sample Output

     [,1] [,2]
[1,]  0.6 -0.7
[2,] -0.2  0.4

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure compute_inverse <- function(matrix) { # Your logic here } # Call the function
Log in or sign up to run or submit your code.Log inSign up
Input
Matrix: 
 [,1] [,2]
[1,] 4 7
[2,] 2 6
Expected Output
     [,1] [,2]
[1,]  0.6 -0.7
[2,] -0.2  0.4