356. Line Reflection
Input: [[1,1],[-1,1]]
Output: trueInput: [[1,1],[-1,-1]]
Output: false解题要点:
class Solution(object):
def isReflected(self, points):
"""
:type points: List[List[int]]
:rtype: bool
"""
pointSet = set()
maxNum = -sys.maxint
minNum = sys.maxint
for x, y in points:
maxNum = max(maxNum, x)
minNum = min(minNum, x)
pointSet.add((x, y))
sumNum = maxNum + minNum
for x, y in points:
tempTuple = (sumNum - x, y)
if tempTuple not in pointSet:
return False
return TrueLast updated