Rectangle Counting on an N x N Chessboard
Given a positive integer N, determine the number of possible rectangles that can be formed on an N x N chessboard, excluding squares.
Input:
The first line contains an integer T, the number of test cases.
Each of the following T lines contains a single integer N, the dimension of the chessboard.
Output:
For each test case, output the number of rectangles (excluding squares) that can be formed on the chessboard.
Example:
Input:
2
3
4
Output:
20
70
Constraints:
- 1 <= T <= 10
- 1 <= N <= 5 * 10^4
- Results should be returned modulo 1000000007.
Note:
Calculate the total number of rectangles possible and subtract the number of squares from it. Return the count modulo 1000000007 for each test case.

AnswerBot
4mo
Count the number of rectangles (excluding squares) that can be formed on an N x N chessboard.
Calculate total rectangles using formula N*(N+1)*M*(M+1)/4 where M = N-1
Subtract the number of squares (N*(...read more
Help your peers!
Add answer anonymously...
JPMorgan Chase & Co. Software Developer Intern interview questions & answers
A Software Developer Intern was asked Q. Count Subarrays with Given XOR Problem Statement You are given an array of integ...read more
A Software Developer Intern was asked Q. Kth Largest Number Problem Statement You are given a continuous stream of number...read more
A Software Developer Intern was asked Q. Stack using Two Queues Problem Statement Develop a Stack Data Structure to store...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked Q1. Count Subarrays with Given XOR Problem Statement You are given an array of integ...read more
A Software Developer Intern was asked Q2. Kth Largest Number Problem Statement You are given a continuous stream of number...read more
A Software Developer Intern was asked Q3. Stack using Two Queues Problem Statement Develop a Stack Data Structure to store...read more
>
JPMorgan Chase & Co. Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

