首页 > 编程语言 > 详细

2021-7-16 在排序数组中查找数字Ⅰ

时间:2021-07-16 10:43:31      阅读:11      评论:0      收藏:0      [点我收藏+]

难度 简单

题目 Leetcode:

剑指Offer 53 - Ⅰ. 在排序数组中查找数字

 

统计一个数字在排序数组中出现的次数。

0 <= array.length() <= 50000

 

题目解析:

懒得解析了,直接map记录,直接输出

以下为参考代码

class Solution {
public:
    int search(vector<int>& nums, int target) {
        unordered_map<int,int>a;
        for(int i:nums)a[i]++;
        return a[target];
    }
};

 

2021-7-16 在排序数组中查找数字Ⅰ

原文:https://www.cnblogs.com/lovetianyi/p/15018540.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!