Time Complexity
The time to create, traverse and fill the 2D grid of size n x n
is n2
, which makes the time complexity of the solution as O(n2)
.
The time to create, traverse and fill the 2D grid of size n x n
is n2
, which makes the time complexity of the solution as O(n2)
.