Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5761 |

@blackshadows | 5715 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4944 |

@saiujwal13083 | 4506 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3516 |

@sushant_a | 3459 |

@verma_ji | 3341 |

@KshamaGupta | 3318 |

Complete Leaderboard | |

Handle | Score |

@aroranayan999 | 1115 |

@bt8816103042 | 739 |

@thealchemist627 | 456 |

@dalwainazism125 | 453 |

@akashkale117 | 453 |

@shivanandp12345678910 | 453 |

@codeantik | 448 |

@SherlockHolmes3 | 447 |

@SHOAIBVIJAPURE | 430 |

@shalinibhataniya1097 | 408 |

@ShamaKhan1 | 392 |

Complete Leaderboard |

You are given a matrix of dimension n*n. All the cells are initially, zero. You are given Q queries, which contains 4 integers a b c d where (a,b) is the TOP LEFT cell and (c,d) is the Bottom Right cell of a submatrix. Now, all the cells of This submatrix has to be incremented by one. After all the Q queries have been performed. Your task is to find the final resulting Matrix.

**Note** : Zero-Based Indexing is used for cells of the matrix.

**Example 1:**

**Input: **n = 6, q = 6,
Queries = {{4,0,5,3},{0,0,3,4},{1,2,1,2}
,{1,1,2,3},{0,0,3,1},{1,0,2,4}}.
**Output: **{{2,1,1,1,0},{3,4,4,3,2,0},{3,4,4,3,2,0}
,{2,2,1,1,1,0},{1,1,1,1,0},{1,1,1,1,0}}

**Your Task:**

You don't need to read or print anything. Your task is to complete the function **solveQueries() **which takes n and Queries and input parameter and returns a matrix after performing all the queries.

**Expected Time Complexity: **O(n^{2})

**Expected Space Complexity: **O(n^{2})

**Constraints:**

1 <= n <= 100

0 <= a <= c <= 99

0 <= b <= d <= 99

1 <= No. of Queries <= 1000

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Queries on a Matrix

...