Count Unique Rectangles in Grid
Given a grid with 'M' rows and 'N' columns, calculate the total number of unique rectangles that can be formed within the grid using its rows and columns.
Input:
The first line contains an integer T, the number of test cases.
Each test case consists of a single line with two space-separated integers, M (number of rows) and N (number of columns).
Output:
For each test case, output a single integer representing the number of unique rectangles that can be formed in the specified grid.
Example:
Input:
2
3 4
2 2
Output:
60
9
Explanation:
For a grid of 3 rows and 4 columns, a total of 60 rectangles can be formed.
Constraints:
- 1 <= T <= 100
- 1 <= N, M <= 104
- Time limit: 1 second
Note:
No need to print the output explicitly; implement the function to return it.
AnswerBot
4d
Calculate the total number of unique rectangles that can be formed within a grid using its rows and columns.
Iterate through all possible combinations of rows and columns to calculate the number of uni...read more
Help your peers!
Add answer anonymously...
Top Snapdeal Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app