#2013

Detect Squares

medium· Math & Geometryruns: 0

Design an algorithm that supports adding new points to a stream and counting the number of axis-aligned squares with a query point as one of the corners. Implement DetectSquares with add(point) that adds a point and count(point) that returns the number of axis-aligned squares with the given point as one corner. Points may be repeated.

sign in to paste and practice your own solution
desktop only

codedrill is a typing game and needs a real keyboard. open this on a laptop or desktop to practice.

you can still browse problems and sections from your phone.