![]() |
Given a matrix, the task is to check if that matrix is a Binary Matrix. A Binary Matrix is a matrix in which all the elements are either 0 or 1. It is also called Logical Matrix, Boolean Matrix, Relation Matrix. Examples: Input: {{1, 0, 1, 1}, {0, 1, 0, 1} {1, 1, 1, 0}} Output: Yes Input: {{1, 0, 1, 1}, {1, 2, 0, 1}, {0, 0, 1, 1}} Output: No Approach: Traverse the matrix and check if every element is either 0 or 1. If there is any element other than 0 and 1, print No else print Yes. Below is the implementation of above approach: C++
Javascript
Output
Yes Complexity Analysis:
|
Reffered: https://www.geeksforgeeks.org
Matrix |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 8 |