The number of times the number that appears in the sort array -python

Ideas: direct traversal again, appears to add 1

# -*- coding:utf-8 -*-
class Solution:
    def GetNumberOfK(self, data, k):
        # write code here
        cnt = 0
        for i in data:
            if i == k:
                cnt += 1
        return cnt

Guess you like

Origin www.cnblogs.com/dolisun/p/11305318.html