title: Why is my limit exceeding on the top k frequent question [LEETCODE]?
body: <p>I have the following code for the Leetcode's top k Frequent question.</p>
  
  <p>The time limit complexity allowed is smaller than <code>o(nlogn)</code>, where n is the array size</p>
  
  <p>Isn't my big <code>O</code> complexity of <code>o(n)</code>?
  If so why am I still exceeding the time limit ?</p>
  
  <pre><code>def topKFrequent(self, nums, k):
          output = {}
          outlist = []
          for item in nums:
              output[item] = nums.count(item)
          max_count = sorted(output.values(),reverse= True)[:k]
          for key,val in output.items():
              if val in max_count:
                  outlist.append(key)
          return (outlist)
  </code></pre>
  
  <p><strong>testinput:</strong> array [1,1,1,2,2,3,1,1,1,2,2,3] k = 2</p>
  
  <p><strong>testoutput:</strong> [1,2]</p>
  
  <p>Question link: <a href="https://leetcode.com/problems/top-k-frequent-elements/" rel="nofollow noreferrer">https://leetcode.com/problems/top-k-frequent-elements/</a></p>