2013. Detect Squares

Practice Detect Squares for free on NudgeCode: Medium, Array & Hash Table pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Keep a collection of points on a grid. Adding the same point more than once keeps every copy.

Each test is a list of operations and their arguments; the expected output lists what each call returns (null for calls that return nothing).

Example

["DetectSquares","add","add","add","count","count","add","count"]
[[],[[3,10]],[[11,2]],[[3,2]],[[11,10]],[[14,8]],[[11,2]],[[11,10]]]
->  [null,null,null,null,1,0,null,2]

Constraints