Update appNew update is available. Click here to update.
sidenav-btnClose
Topic list
Rectangles In N x N Board
MEDIUM
20 mins
7 upvotes
Other topics
Problem solved
Badge
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
Linked List
-
-
Sorting
-
-
Binary Search
-
-
Stacks & Queues
-
-
Trees
-
-
Graph
-
-
Dynamic Programming
-
-
Greedy
-
-
Tries
-
-
Arrays
-
-
SQL
-
-
Binary Search Trees
-
-
Heap
-
-
Bit Manipulation
-
-
Solve problems & track your progress
Checkout your overall progress in every topic here
Become
userLevel
Sensei
in DSA topics
Open the topic and solve more problems associated with it to improve your skills
Check out the skill meter for every topic
See how many problems you are left with to solve for cracking any stage. Score more than zero to get your progress counted.

Rectangles In N x N Board

Contributed by
Shivam Mehla
Medium
yellow-spark
0/80
Avg time to solve 20 mins
Success Rate 80 %
Share
7 upvotes

Problem Statement

You are given a positive integer N. Your task is to find the number of possible rectangles, excluding squares, in a N x N chessboard.

Example:
Let’s assume that we have a chessboard of dimension 4x4, i.e. N = 4. Then the rectangles can have the following possible dimensions: {1*2, 1*3, 1*4, 2*1, ……, 2*4, ………,4*4}. So, the total number of rectangles in the chessboard is 70.
Detailed explanation ( Input/output format, Notes, Constraints, Images )
Sample Input 1:
2
4
1
Sample Output 1:
70
0
Explanation For Sample Input 1:
For the first test case refer to the example explained above.

For the second test case we have, a chessboard of dimension 1x1, i.e. N = 1. There are no possible rectangles. Hence, the answer is zero.
Sample Input 2:
2
2
5
Sample Output 2:
4
170
Reset Code
Full screen
Auto
copy-code
Console