Leetcode 963.Minimum Area Rectan
作者:
lee_5a30 | 来源:发表于
2018-12-23 12:28 被阅读0次**Python:**
def minAreaFreeRect(self, points):
points = [complex(*z) for z in sorted(points)]
seen = collections.defaultdict(list)
for P, Q in itertools.combinations(points, 2):
seen[Q - P].append((P + Q) / 2)
ans = float("inf")
for A, candidates in seen.iteritems():
for P, Q in itertools.combinations(candidates, 2):
if A.real * (P - Q).real == -A.imag * (P - Q).imag:
ans = min(ans, abs(A) * abs(P - Q))
return ans if ans < float("inf") else 0
本文标题:Leetcode 963.Minimum Area Rectan
本文链接:https://www.haomeiwen.com/subject/ngtnkqtx.html
网友评论