Please correct the Memory Limit Exceeded Error for python


  • 0
    M

    @administrators
    I have following code, which passed all the 42 cases but did not get accepted because of memory limit exceeded Error, which I believe is a mistake. It just uses O(1) memory here.

    class Solution(object):
        def getIntersectionNode(self, headA, headB):
            """
            :type head1, head1: ListNode
            :rtype: ListNode
            """
            a, b = headA, headB
            if not a or not b:
                return None
            
            while a != b:
                a = a.next if a else headB
                b = b.next if b else headA
                
            return a
    

Log in to reply
 

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