New update is available. Click here to update.
Close
Topic list
Rectangles In N x N Board
MEDIUM
20 mins
Other topics
Problem solved
Skill meter
Strings
-
-
Matrices (2D Arrays)
-
-
-
-
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
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
0/80
Avg time to solve 20 mins
Success Rate 80 %
Share

## 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
``````
Auto
Console