Given a grid of side N * N, the task is to find the total number of squares that exist inside it. All squares selected can be of any length.
Input: N = 1
Input: N = 2
Input: N = 4
Approach: Taking a few examples, it can be observed that for a grid on size N * N, the number of squares inside it will be 12 + 22 + 32 + … + N2
Below is the implementation of the above approach:
- Find a point that lies inside exactly K given squares
- Sum of the count of number of adjacent squares in an M X N grid
- Find the Side of the smallest Square that can contain given 4 Big Squares
- Square pyramidal number (Sum of Squares)
- Find the side of the squares which are lined in a row, and distance between the centers of first and last square is given
- Count Magic squares in a grid
- Sum of Area of all possible square inside a rectangle
- Area of a leaf inside a square
- Maximum perimeter of a square in a 2D grid
- Puzzle | Program to find number of squares in a chessboard
- Find minimum number to be divided to make a number a perfect square
- Find the Next perfect square greater than a given number
- Find the number of rectangles of size 2*1 which can be placed inside a rectangle of size n*m
- Find square root of number upto given precision using binary search
- Check if a number is perfect square without finding square root
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.