← All problemsSign in

CountSquares

You are given a binary matrix of size $n*n$. A binary matrix is defined as a matrix consisting of only 0's and 1's. Formally a square of side $s$ having coordinate $(a, b)$ as its top left corner is defined as the region of coordinates $(i,j)$ where $a$ $\leq$ $i$ $\leq$ $a+s-1$ and $b$ $\leq$ $j$ $\leq$ $b+s-1$ and its boundary is defined as the set of coordinates $(i,j)$ of the square where $i=a

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start