A Boolean Matrix Question
Last Updated :
11 Dec, 2024
Given a boolean matrix mat where each cell contains either 0 or 1, the task is to modify it such that if a matrix cell matrix[i][j] is 1 then all the cells in its ith row and jth column will become 1.
Examples:
Input: [[1, 0],
[0, 0]]
Output: [[1, 1],
[1, 0]]
Input: [[1, 0, 0, 1],
[0, 0, 1, 0],
[0, 0, 0, 0]]
Output: [[1, 1, 1, 1],
[1, 1, 1, 1],
[1, 0, 1, 1]]
[Naive Approach] By Marking the Matrix
Assuming all the elements in the matrix are non-negative. Traverse through the matrix and if you find an element with value 1, then change all the zeros in its row and column to -1. The reason for not changing other elements to 1, but -1, is because that might affect other columns and rows.
Now traverse through the matrix again and if an element is -1 change it to 1, which will be the answer.
C++
// C++ Code For Boolean Matrix Question
// By Marking the Matrix
#include <iostream>
#include <vector>
using namespace std;
void booleanMatrix(vector<vector<int>>& mat) {
int rows = mat.size(), cols = mat[0].size();
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (mat[i][j] == 1) {
// Replace all the zeros in jth column by -1
for (int idx = 0; idx < rows; idx++) {
if (mat[idx][j] == 0) {
mat[idx][j] = -1;
}
}
// Replace all the zeros in ith row by -1
for (int idx = 0; idx < cols; idx++) {
if (mat[i][idx] == 0) {
mat[i][idx] = -1;
}
}
}
}
}
// Replace all the -1 by 1
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (mat[i][j] == -1) {
mat[i][j] = 1;
}
}
}
}
int main() {
vector<vector<int>> mat = {{1, 0, 0, 1}, {0, 0, 1, 0}, {0, 0, 0, 0}};
booleanMatrix(mat);
for (const vector<int>& row : mat) {
for (int val : row) {
cout << val << " ";
}
cout << endl;
}
return 0;
}
Java
// Java Code For Boolean Matrix Question
// By Marking the Matrix
class GfG {
static void booleanMatrix(int[][] mat) {
int rows = mat.length, cols = mat[0].length;
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (mat[i][j] == 1) {
// Replace all the zeros in jth column by -1
for (int idx = 0; idx < rows; idx++) {
if (mat[idx][j] == 0) {
mat[idx][j] = -1;
}
}
// Replace all the zeros in ith row by -1
for (int idx = 0; idx < cols; idx++) {
if (mat[i][idx] == 0) {
mat[i][idx] = -1;
}
}
}
}
}
// Replace all the -1 by 1
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (mat[i][j] == -1) {
mat[i][j] = 1;
}
}
}
}
public static void main(String[] args) {
int[][] mat = {{1, 0, 0, 1}, {0, 0, 1, 0}, {0, 0, 0, 0}};
booleanMatrix(mat);
for (int[] row : mat) {
for (int val : row) {
System.out.print(val + " ");
}
System.out.println();
}
}
}
Python
# python3 Code For Boolean Matrix Question
# By Marking the Matrix
def booleanMatrix(mat):
rows, cols = len(mat), len(mat[0])
for i in range(rows):
for j in range(cols):
if mat[i][j] == 1:
# Replace all the zeros in jth column by -1
for idx in range(rows):
if mat[idx][j] == 0:
mat[idx][j] = -1
# Replace all the zeros in ith row by -1
for idx in range(cols):
if mat[i][idx] == 0:
mat[i][idx] = -1
# Replace all the -1 by 1
for i in range(rows):
for j in range(cols):
if mat[i][j] == -1:
mat[i][j] = 1
if __name__ == "__main__":
mat = [[1, 0, 0, 1], [0, 0, 1, 0], [0, 0, 0, 0]]
booleanMatrix(mat)
for row in mat:
print(" ".join(map(str, row)))
C#
// C# Code For Boolean Matrix Question
// By Marking the Matrix
using System;
class GfG {
static void booleanMatrix(int[, ] mat) {
int rows = mat.GetLength(0), cols = mat.GetLength(1);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (mat[i, j] == 1) {
// Replace all the zeros in jth column
// by -1
for (int idx = 0; idx < rows; idx++) {
if (mat[idx, j] == 0) {
mat[idx, j] = -1;
}
}
// Replace all the zeros in ith row by
// -1
for (int idx = 0; idx < cols; idx++) {
if (mat[i, idx] == 0) {
mat[i, idx] = -1;
}
}
}
}
}
// Replace all the -1 by 1
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (mat[i, j] == -1) {
mat[i, j] = 1;
}
}
}
}
static void Main() {
int[, ] mat = { { 1, 0, 0, 1 },
{ 0, 0, 1, 0 },
{ 0, 0, 0, 0 } };
booleanMatrix(mat);
for (int i = 0; i < mat.GetLength(0); i++) {
for (int j = 0; j < mat.GetLength(1); j++) {
Console.Write(mat[i, j] + " ");
}
Console.WriteLine();
}
}
}
JavaScript
// Javascript Code For Boolean Matrix Question
// By Marking the Matrix
function booleanMatrix(mat) {
let rows = mat.length, cols = mat[0].length;
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
if (mat[i][j] === 1) {
// Replace all the zeros in jth column by -1
for (let idx = 0; idx < rows; idx++) {
if (mat[idx][j] === 0) {
mat[idx][j] = -1;
}
}
// Replace all the zeros in ith row by -1
for (let idx = 0; idx < cols; idx++) {
if (mat[i][idx] === 0) {
mat[i][idx] = -1;
}
}
}
}
}
// Replace all the -1 by 1
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
if (mat[i][j] === -1) {
mat[i][j] = 1;
}
}
}
}
// Driver Code
let mat = [[1, 0, 0, 1], [0, 0, 1, 0], [0, 0, 0, 0]];
booleanMatrix(mat);
mat.forEach(row => {
console.log(row.join(' '));
});
Output1 1 1 1
1 1 1 1
1 0 1 1
Time Complexity: O((n * m)*(n + m)) where n is number of rows and m is number of columns in given matrix.
O(n * m) for traversing through each element and (n+m) for traversing to row and column of matrix elements having value 1.
Space Complexity: O(1)
[Better Approach] Using Extra Space
The idea is to use two temporary arrays, rowMarker
[]
and colMarker[]
, to keep track of which rows and columns need to be updated.
Following are the steps for this approach
- Create two temporary arrays rowMarker[] and colMarker[]. Initialize all values of rowMarker[] and colMarker[] as 0.
- Traverse the input matrix mat[][]. If you finds mat[i][j] as 1, then mark rowMarker[i] and colMarker[j] as true.
- Traverse the input matrix mat[][] again. For each entry mat[i][j], check the values of rowMarker[i] and colMarker[j]. If any of the two values (rowMarker[i] or colMarker[j]) is true, then mark mat[i][j] as 1.
C++
// C++ Code For Boolean Matrix Question
// Using two extra arrays
#include <iostream>
#include <vector>
using namespace std;
void booleanMatrix(vector<vector<int>>& mat) {
int rows = mat.size();
int cols = mat[0].size();
// Arrays to keep track of rows and columns to be updated
vector<bool> rowMarker(rows, false);
vector<bool> colMarker(cols, false);
// Mark the rows and columns that need to be updated
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (mat[i][j] == 1) {
rowMarker[i] = true;
colMarker[j] = true;
}
}
}
// Update the matrix
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (rowMarker[i] || colMarker[j]) {
mat[i][j] = 1;
}
}
}
}
int main() {
vector<vector<int>> mat = {
{1, 0, 0, 1},
{0, 0, 1, 0},
{0, 0, 0, 0}
};
booleanMatrix(mat);
for (const vector<int>& row : mat) {
for (int val : row) {
cout << val << " ";
}
cout << endl;
}
return 0;
}
Java
// Java Code For Boolean Matrix Question
// Using two extra arrays
import java.util.*;
class GfG {
static void booleanMatrix(int mat[][]) {
int rows = mat.length;
int cols = mat[0].length;
// Arrays to keep track of rows and columns to be marked
boolean[] rowMarker = new boolean[rows];
boolean[] colMarker = new boolean[cols];
// First pass: Mark the rows and columns to be updated
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (mat[i][j] == 1) {
rowMarker[i] = true;
colMarker[j] = true;
}
}
}
// Second pass: Update the matrix
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (rowMarker[i] || colMarker[j]) {
mat[i][j] = 1;
}
}
}
}
public static void main(String[] args) {
int[][] arr = {
{ 1, 0, 0, 1 },
{ 0, 0, 1, 0 },
{ 0, 0, 0, 0 }
};
booleanMatrix(arr);
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[0].length; j++) {
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}
Python
# python3 Code For Boolean Matrix Question
# Using two extra arrays
def booleanMatrix(mat):
rows = len(mat)
cols = len(mat[0])
# Arrays to keep track of rows and columns to be updated
rowMarker = [False] * rows
colMarker = [False] * cols
# First pass: Mark the rows and columns to be updated
for i in range(rows):
for j in range(cols):
if mat[i][j] == 1:
rowMarker[i] = True
colMarker[j] = True
# Second pass: Update the matrix
for i in range(rows):
for j in range(cols):
if rowMarker[i] or colMarker[j]:
mat[i][j] = 1
if __name__ == "__main__":
arr = [[1, 0, 0, 1],
[0, 0, 1, 0],
[0, 0, 0, 0]]
booleanMatrix(arr)
for row in arr:
print(" ".join(map(str, row)))
C#
// C# Code For Boolean Matrix Question
// Using two extra arrays
using System;
using System.Collections.Generic;
class GfG {
static void booleanMatrix(List<List<int>> mat) {
int rows = mat.Count;
int cols = mat[0].Count;
// Arrays to keep track of rows and columns to be updated
bool[] rowMarker = new bool[rows];
bool[] colMarker = new bool[cols];
// First pass: Mark the rows and columns to be updated
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (mat[i][j] == 1) {
rowMarker[i] = true;
colMarker[j] = true;
}
}
}
// Second pass: Update the matrix
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
if (rowMarker[i] || colMarker[j]) {
mat[i][j] = 1;
}
}
}
}
// Test the BooleanMatrix function with a sample input
static void Main(string[] args) {
List<List<int>> arr = new List<List<int>> {
new List<int>{ 1, 0, 0, 1 },
new List<int>{ 0, 0, 1, 0 },
new List<int>{ 0, 0, 0, 0 }
};
booleanMatrix(arr);
foreach (var row in arr) {
Console.WriteLine(string.Join(" ", row));
}
}
}
JavaScript
// Javascript Code For Boolean Matrix Question
// Using two extra arrays
function booleanMatrix(mat) {
const rows = mat.length;
const cols = mat[0].length;
// Arrays to keep track of rows and columns to be
// updated
const rowMarker = new Array(rows).fill(false);
const colMarker = new Array(cols).fill(false);
// First pass: Mark the rows and columns to be updated
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
if (mat[i][j] === 1) {
rowMarker[i] = true;
colMarker[j] = true;
}
}
}
// Second pass: Update the matrix
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
if (rowMarker[i] || colMarker[j]) {
mat[i][j] = 1;
}
}
}
}
// Driver Code
const arr = [ [ 1, 0, 0, 1 ],
[ 0, 0, 1, 0 ],
[ 0, 0, 0, 0 ] ];
booleanMatrix(arr);
arr.forEach(row => console.log(row.join(" ")));
Output1 1 1 1
1 1 1 1
1 0 1 1
Time Complexity: O(n * m) where n is number of rows and m is number of columns in given matrix.
Auxiliary Space: O(n + m) as we are taking two arrays one of size m and another of size n.
[Expected Approach] Without Using Extra Space
Instead of taking two dummy arrays we can use the first row and first column of the matrix for the same work. This will help to reduce the space complexity of the problem. While traversing for the second time, the first row and column will be computed first, which will affect the values of further elements. So we traverse in the reverse direction.
Since matrix[0][0] are overlapping in first row and first column. Therefore take separate variable col0 (say) to check if the 0th column has 1 or not and use matrix[0][0] to check if the 0th row has 1 or not. Now traverse from the last element to the first element and check if matrix[i][0]==1 || matrix[0][j]==1 and if true set matrix[i][j]=1, else continue.
C++
// C++ Code For Boolean Matrix Question
// Most Optimised Approach
#include <iostream>
#include <vector>
using namespace std;
void booleanMatrix(vector<vector<int>>& mat) {
int col0 = 0, rows = mat.size(),
cols = mat[0].size();
// Step 1: Mark the first row and
// column if there is a 1 in the matrix
for (int i = 0; i < rows; i++) {
// Check if 0th column contains 1
if (mat[i][0] == 1) col0 = 1;
for (int j = 1; j < cols; j++) {
if (mat[i][j] == 1) {
mat[i][0] = 1;
mat[0][j] = 1;
}
}
}
// Step 2: Traverse the matrix in
// reverse direction and update values
for (int i = rows - 1; i >= 0; i--) {
for (int j = cols - 1; j >= 1; j--) {
if (mat[i][0] == 1 || mat[0][j] == 1) {
mat[i][j] = 1;
}
}
if (col0 == 1) {
mat[i][0] = 1;
}
}
}
int main() {
vector<vector<int>> arr = {{1, 0, 0, 1},
{0, 0, 1, 0},
{0, 0, 0, 0}};
booleanMatrix(arr);
for (int i = 0; i < arr.size(); i++) {
for (int j = 0; j < arr[0].size(); j++) {
cout << arr[i][j] << " ";
}
cout << endl;
}
return 0;
}
Java
// Java Code For Boolean Matrix Question
// Most Optimised Approach
import java.util.*;
class GfG {
static void booleanMatrix(int mat[][]) {
int col0 = 0;
int rows = mat.length, cols = mat[0].length;
// Step 1: Mark the first row and
// column if there is a 1 in the matrix
for (int i = 0; i < rows; i++) {
// Check if 0th column contains 1
if (mat[i][0] == 1) col0 = 1;
for (int j = 1; j < cols; j++) {
if (mat[i][j] == 1) {
mat[i][0] = 1;
mat[0][j] = 1;
}
}
}
// Step 2: Traverse the matrix in reverse
// direction and update values
for (int i = rows - 1; i >= 0; i--) {
for (int j = cols - 1; j >= 1; j--) {
if (mat[i][0] == 1 || mat[0][j] == 1) {
mat[i][j] = 1;
}
}
if (col0 == 1) {
mat[i][0] = 1;
}
}
}
public static void main(String[] args) {
int[][] arr = {
{1, 0, 0, 1},
{0, 0, 1, 0},
{0, 0, 0, 0}
};
booleanMatrix(arr);
for (int i = 0; i < arr.length; i++) {
for (int j = 0; j < arr[0].length; j++) {
System.out.print(arr[i][j] + " ");
}
System.out.println();
}
}
}
Python
# python3 Code For Boolean Matrix Question
# Most Optimised Approach
def booleanMatrix(mat):
col0 = 0
rows = len(mat)
cols = len(mat[0])
# Step 1: Mark the first row and column
# if there is a 1 in the matrix
for i in range(rows):
# Check if 0th column contains 1
if mat[i][0] == 1:
col0 = 1
for j in range(1, cols):
if mat[i][j] == 1:
mat[i][0] = 1
mat[0][j] = 1
# Step 2: Traverse the matrix in reverse
# direction and update values
for i in range(rows - 1, -1, -1):
for j in range(cols - 1, 0, -1):
if mat[i][0] == 1 or mat[0][j] == 1:
mat[i][j] = 1
if col0 == 1:
mat[i][0] = 1
if __name__ == "__main__":
arr = [
[1, 0, 0, 1],
[0, 0, 1, 0],
[0, 0, 0, 0]
]
booleanMatrix(arr)
for row in arr:
print(" ".join(map(str, row)))
C#
// C# Code For Boolean Matrix Question
// Most Optimised Approach
using System;
class GfG {
static void booleanMatrix(int[,] mat) {
int col0 = 0, rows = mat.GetLength(0),
cols = mat.GetLength(1);
// Step 1: Mark the first row and column
// if there is a 1 in the matrix
for (int i = 0; i < rows; i++) {
// Check if 0th column contains 1
if (mat[i, 0] == 1) col0 = 1;
for (int j = 1; j < cols; j++) {
if (mat[i, j] == 1) {
mat[i, 0] = 1;
mat[0, j] = 1;
}
}
}
// Step 2: Traverse the matrix in reverse
// direction and update values
for (int i = rows - 1; i >= 0; i--) {
for (int j = cols - 1; j >= 1; j--) {
if (mat[i, 0] == 1 || mat[0, j] == 1) {
mat[i, j] = 1;
}
}
if (col0 == 1) {
mat[i, 0] = 1;
}
}
}
static void Main() {
int[,] arr = {
{1, 0, 0, 1},
{0, 0, 1, 0},
{0, 0, 0, 0}
};
booleanMatrix(arr);
for (int i = 0; i < arr.GetLength(0); i++) {
for (int j = 0; j < arr.GetLength(1); j++) {
Console.Write(arr[i, j] + " ");
}
Console.WriteLine();
}
}
}
JavaScript
// Javascript Code For Boolean Matrix Question
// Most Optimised Approach
function booleanMatrix(mat) {
let col0 = 0;
const rows = mat.length;
const cols = mat[0].length;
// Step 1: Mark the first row and column
// if there is a 1 in the matrix
for (let i = 0; i < rows; i++) {
// Check if 0th column contains 1
if (mat[i][0] === 1) col0 = 1;
for (let j = 1; j < cols; j++) {
if (mat[i][j] === 1) {
mat[i][0] = 1;
mat[0][j] = 1;
}
}
}
// Step 2: Traverse the matrix in reverse direction and update values
for (let i = rows - 1; i >= 0; i--) {
for (let j = cols - 1; j >= 1; j--) {
if (mat[i][0] === 1 || mat[0][j] === 1) {
mat[i][j] = 1;
}
}
if (col0 === 1) {
mat[i][0] = 1;
}
}
}
// Driver Code
const arr = [
[1, 0, 0, 1],
[0, 0, 1, 0],
[0, 0, 0, 0]
];
booleanMatrix(arr);
for (let i = 0; i < arr.length; i++) {
console.log(arr[i].join(" "));
}
Output1 1 1 1
1 1 1 1
1 0 1 1
Time Complexity: O(n * m) where n is number of rows and m is number of columns in given matrix.
Auxiliary Space: O(1)
A Boolean Matrix Problem | DSA Problem
Similar Reads
Basics & Prerequisites
Data Structures
Array Data StructureIn this article, we introduce array, implementation in different popular languages, its basic operations and commonly seen problems / interview questions. An array stores items (in case of C/C++ and Java Primitive Arrays) or their references (in case of Python, JS, Java Non-Primitive) at contiguous
3 min read
String in Data StructureA string is a sequence of characters. The following facts make string an interesting data structure.Small set of elements. Unlike normal array, strings typically have smaller set of items. For example, lowercase English alphabet has only 26 characters. ASCII has only 256 characters.Strings are immut
2 min read
Hashing in Data StructureHashing is a technique used in data structures that efficiently stores and retrieves data in a way that allows for quick access. Hashing involves mapping data to a specific index in a hash table (an array of items) using a hash function. It enables fast retrieval of information based on its key. The
2 min read
Linked List Data StructureA linked list is a fundamental data structure in computer science. It mainly allows efficient insertion and deletion operations compared to arrays. Like arrays, it is also used to implement other data structures like stack, queue and deque. Hereâs the comparison of Linked List vs Arrays Linked List:
2 min read
Stack Data StructureA Stack is a linear data structure that follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out). LIFO implies that the element that is inserted last, comes out first and FILO implies that the element that is inserted first
2 min read
Queue Data StructureA Queue Data Structure is a fundamental concept in computer science used for storing and managing data in a specific order. It follows the principle of "First in, First out" (FIFO), where the first element added to the queue is the first one to be removed. It is used as a buffer in computer systems
2 min read
Tree Data StructureTree Data Structure is a non-linear data structure in which a collection of elements known as nodes are connected to each other via edges such that there exists exactly one path between any two nodes. Types of TreeBinary Tree : Every node has at most two childrenTernary Tree : Every node has at most
4 min read
Graph Data StructureGraph Data Structure is a collection of nodes connected by edges. It's used to represent relationships between different entities. If you are looking for topic-wise list of problems on different topics like DFS, BFS, Topological Sort, Shortest Path, etc., please refer to Graph Algorithms. Basics of
3 min read
Trie Data StructureThe Trie data structure is a tree-like structure used for storing a dynamic set of strings. It allows for efficient retrieval and storage of keys, making it highly effective in handling large datasets. Trie supports operations such as insertion, search, deletion of keys, and prefix searches. In this
15+ min read
Algorithms
Searching AlgorithmsSearching algorithms are essential tools in computer science used to locate specific items within a collection of data. In this tutorial, we are mainly going to focus upon searching in an array. When we search an item in an array, there are two most common algorithms used based on the type of input
2 min read
Sorting AlgorithmsA Sorting Algorithm is used to rearrange a given array or list of elements in an order. For example, a given array [10, 20, 5, 2] becomes [2, 5, 10, 20] after sorting in increasing order and becomes [20, 10, 5, 2] after sorting in decreasing order. There exist different sorting algorithms for differ
3 min read
Introduction to RecursionThe process in which a function calls itself directly or indirectly is called recursion and the corresponding function is called a recursive function. A recursive algorithm takes one step toward solution and then recursively call itself to further move. The algorithm stops once we reach the solution
14 min read
Greedy AlgorithmsGreedy algorithms are a class of algorithms that make locally optimal choices at each step with the hope of finding a global optimum solution. At every step of the algorithm, we make a choice that looks the best at the moment. To make the choice, we sometimes sort the array so that we can always get
3 min read
Graph AlgorithmsGraph is a non-linear data structure like tree data structure. The limitation of tree is, it can only represent hierarchical data. For situations where nodes or vertices are randomly connected with each other other, we use Graph. Example situations where we use graph data structure are, a social net
3 min read
Dynamic Programming or DPDynamic Programming is an algorithmic technique with the following properties.It is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for the same inputs, we can optimize it using Dynamic Programming. The idea is to simply store the results of
3 min read
Bitwise AlgorithmsBitwise algorithms in Data Structures and Algorithms (DSA) involve manipulating individual bits of binary representations of numbers to perform operations efficiently. These algorithms utilize bitwise operators like AND, OR, XOR, NOT, Left Shift, and Right Shift.BasicsIntroduction to Bitwise Algorit
4 min read
Advanced
Segment TreeSegment Tree is a data structure that allows efficient querying and updating of intervals or segments of an array. It is particularly useful for problems involving range queries, such as finding the sum, minimum, maximum, or any other operation over a specific range of elements in an array. The tree
3 min read
Pattern SearchingPattern searching algorithms are essential tools in computer science and data processing. These algorithms are designed to efficiently find a particular pattern within a larger set of data. Patten SearchingImportant Pattern Searching Algorithms:Naive String Matching : A Simple Algorithm that works i
2 min read
GeometryGeometry is a branch of mathematics that studies the properties, measurements, and relationships of points, lines, angles, surfaces, and solids. From basic lines and angles to complex structures, it helps us understand the world around us.Geometry for Students and BeginnersThis section covers key br
2 min read
Interview Preparation
Practice Problem