My python solution beat 100%, is this cheating, Should I use 2 pointer?


  • 0
    G
    enter code hereclass Solution(object):
    def isPalindrome(self, head):
        """
        :type head: ListNode
        :rtype: bool
        """
        temp=[]
        while head:
            temp.append(head.val)
            head=head.next
        
        compare=temp*1
        compare.reverse()
        return temp==compare

  • 0
    F

    Your solution used O(n) space instead of O(1)


Log in to reply
 

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