you give stream point XY plane Design algorithm thatadd new point stream data structure Duplicate point allow treat different pointsgiven query point count number way choose point data structure point query point form axisaligne square positive areaan axisaligne square square edge length parallel perpendicular xaxis yaxisimplement DetectSquares classdetectsquare Initializes object datum structurevoid addint point add new point point x y data structureint countint point count number way form axisaligne square point point x y describe Example 1inputdetectsquares add add add count count add count 3 10 11 2 3 2 11 10 14 8 11 2 11 10outputnull null null null 1 0 null 2explanationdetectsquares detectsquare new DetectSquaresdetectSquaresadd3 10detectSquaresadd11 2detectsquaresadd3 2detectsquarescount11 10 return 1 you choose the second pointsdetectsquarescount14 8 return 0 the query point form square point datum structuredetectSquaresadd11 2 add duplicate point alloweddetectsquarescount11 10 return 2 you choose the second point the fourth point Constraintspointlength 20 x y 1000at 3000 call total add count