<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>几何 on Algorithm Solutions</title><link>https://algorithm.liangqin.ren/tags/%E5%87%A0%E4%BD%95/</link><description>Recent content in 几何 on Algorithm Solutions</description><generator>Hugo -- gohugo.io</generator><lastBuildDate>Mon, 12 Oct 2026 11:39:49 -0500</lastBuildDate><atom:link href="https://algorithm.liangqin.ren/tags/%E5%87%A0%E4%BD%95/index.xml" rel="self" type="application/rss+xml"/><item><title>8. 统计坐标轴平行的正方形数量</title><link>https://algorithm.liangqin.ren/oa/8/</link><pubDate>Mon, 12 Oct 2026 11:39:49 -0500</pubDate><guid>https://algorithm.liangqin.ren/oa/8/</guid><description>1. Description 给定平面上的 n 个互不相同的整数坐标点，每个点表示为 (x, y)。
从中选择四个不同的点，如果满足以下条件，则称它们构成一个合法正方形：
四个点恰好是一个正方形的四个顶点。 正方形的四条边均平行于坐标轴，且边长大于 0。 除这四个顶点外，不存在其他给定点位于正方形内部或边界上。 请返回所有不同合法正方形的数量。
2. Solution n = points.size()
Time complexity: O(n$^2$)
Space complexity: O(n)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 class Solution { public: int countSquares(vector&amp;lt;vector&amp;lt;int&amp;gt;&amp;gt;&amp;amp; points) { const int n = points.</description></item></channel></rss>