why is this O(n) solution exceed time limit


  • 0

    I saw some other O(n) solution is correct, but this one is also O(n), why exceed time limit?

    class Solution(object):
        def findDuplicates(self, nums):
    
            if not nums:
                return []
            
            res = list(set([i for i in nums if nums.count(i) > 1]))
            
            return res
    

Log in to reply
 

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