← Back to challenges

Determinant of Square Matrix

JavaScriptHardalgebraalgorithmsinterviewmath

Instructions

In linear algebra, the determinant is a scalar value that can be computed from the elements of a square matrix and encodes certain properties of the linear transformation described by the matrix.

Create a function that takes a square 2D array as an argument and returns a number (determinant).

Examples

getDet([
  [ 0, 1],
  [ 1, 1]
]) ➞ -1

getDet([
  [69, 0],
  [1, 1]
]) ➞ 69

getDet([
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
]) ➞ 0

Notes

N/A

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.