数字在排序数组中出现的次数-python

思路:直接遍历一遍,出现就加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
原文地址:https://www.cnblogs.com/dolisun/p/11305318.html