数字在排序数组中出现的次数-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
posted @ 2019-08-05 20:21  Dolisun  阅读(426)  评论(0编辑  收藏  举报