My focus is on the last element.Is it OK?

  • 0

    class Solution(object):
    def singleNonDuplicate(self, nums):

        def f(n):
            if len(n) == 1:
                return n[-1]
            if n[-1] != n[-2]:
                return n[-1]
            if len(n) > 1:
                del n[-1]
                del n[-1]
                return f(n)
        return f(nums)

Log in to reply

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