My wrong solution got accepted-testcase missing


  • 1
    S

    For testcase [[-16,1],[16,1],[16,1]], my code below will return True but expected answer is False.
    When I submit, it got accepted.
    However, if I click on Run Code and use this testcase, it will show correctly that expected answer is False, and my return is True.

    class Solution(object):
        def isReflected(self, points):
            """
            :type points: List[List[int]]
            :rtype: bool
            """
            if not points:
                return True
    
            xList = [point[0] for point in points]
            minX = min(xList)
            maxX = max(xList)
            
            reflectX = (minX+maxX)/2.0
            
            table= collections.defaultdict(int)
            for point in points:
                table[(point[0], point[1])] += 1
    
            for point in points:
                if point[0] == reflectX:
                    continue
                if (2*reflectX-point[0], point[1]) in table and (point[0], point[1]) in table:
                    table[(2*reflectX-point[0], point[1])] -= 1
                    table[(point[0], point[1])] -= 1
                    continue
                else:
                    return False
            return True

  • 0
    S

    For this same testcase [[-16,1],[16,1],[16,1]], if I click on Run Code under Java with a Java solution, it will show expected answer as true. and if I click on Run Code under Python, it will show expected answer as false. inconsistent ?


  • 0
    F

    @admin may want to take a look at it.


  • 0

    Thanks, I have added your test case. For your test case it should return True, because the problem description did not mention the requirement that each reflected point must be unique. Many points can reflect on the same point, it does not matter.


Log in to reply
 

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