Created
March 5, 2020 21:34
-
-
Save syphh/4a8202f1a06b213ed2ecbd9fb454edea to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isLowerTriangular(mat){ | |
| let matSize = mat.length; | |
| for(let i = 0; i < matSize; i++){ | |
| for(let j = i+1; j < matSize; j++){ | |
| if(mat[i][j] != 0) | |
| return false; | |
| } | |
| } | |
| return true; | |
| } | |
| let mat1 = [[2, 0, 0, 0], | |
| [9, 5, 0, 0], | |
| [8, 2, 4, 0], | |
| [9, 4, 8, 3]]; | |
| let mat2 = [[1, 8, 3, 2], | |
| [0, 5, 7, 6], | |
| [7, 8, 4, 9], | |
| [8, 6, 3, 3]]; | |
| console.log(isLowerTriangular(mat1)); | |
| console.log(isLowerTriangular(mat2)); | |
| /*Output: | |
| true | |
| false | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment