Why this python code 'compile error'?

  • 0

    Below is my python code to "Max Points on a Line", I test it locally with lots test points and it's ok, but the oj reply "Compile Error".

    Is there anything I missed?

    import operator
    class Solution:
        # @param points, a list of Points
        # @return an integer
        def maxPoints(self, points):
            pointset = set(points)
            if len(pointset) < 3:
                return len(points)
                pointdict ={pkey:points.count(pkey) for pkey in pointset}
                count = 0
                while len(pointset) > 1:
                    point1 = pointset.pop()
                    point2set = pointset.copy()
                    while point2set:
                        point2 = point2set.pop()
                        point3set = point2set.copy()
                        lineset = {point1, point2}
                        if point3set:
                            for point3 in point3set:
                                if (point1.x-point2.x)*(point2.y-point3.y) == (point2.x-point3.x)*(point1.y-point2.y) :
                        linecount = reduce(operator.add, [pointdict[p] for p in lineset])
                        if linecount > count: 
                            count = linecount
                return count

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.