当前位置: 首页 > news >正文

网站怎么做动效搜索网站哪个好

网站怎么做动效,搜索网站哪个好,百度网站检测,百度怎么做公司的网站题目链接 Leetcode.275 H 指数 II mid 题目描述 给你一个整数数组 c i t a t i o n s citations citations ,其中 c i t a t i o n s [ i ] citations[i] citations[i] 表示研究者的第 i i i 篇论文被引用的次数, c i t a t i o n s citations citat…

题目链接

Leetcode.275 H 指数 II mid

题目描述

给你一个整数数组 c i t a t i o n s citations citations ,其中 c i t a t i o n s [ i ] citations[i] citations[i] 表示研究者的第 i i i 篇论文被引用的次数, c i t a t i o n s citations citations 已经按照 升序排列 。计算并返回该研究者的 h h h 指数

h h h 指数的定义: h h h 代表“高引用次数”( h i g h c i t a t i o n s high citations highcitations),一名科研人员的 h h h 指数是指他(她)的 ( n n n 篇论文中)总共有 h h h 篇论文分别被引用了至少 h h h 次。

请你设计并实现对数时间复杂度的算法解决此问题。

示例 1:

输入:citations = [0,1,3,5,6]
输出:3
解释:给定数组表示研究者总共有 5 篇论文,每篇论文相应的被引用了 0, 1, 3, 5, 6 次。
由于研究者有3篇论文每篇 至少 被引用了 3 次,其余两篇论文每篇被引用 不多于 3 次,所以她的 h 指数是 3 。

示例 2:

输入:citations = [1,2,100]
输出:2

提示:
  • n = c i t a t i o n s . l e n g t h n = citations.length n=citations.length
  • 1 ≤ n ≤ 1 0 5 1 \leq n \leq 10^5 1n105
  • 0 ≤ c i t a t i o n s [ i ] ≤ 1000 0 \leq citations[i] \leq 1000 0citations[i]1000
  • c i t a t i o n s citations citations升序排列

解法:二分

初始 l = 0 , r = n l = 0 , r = n l=0,r=n

我们可以得到 m i d mid mid ,如果 c i t a t i o n s citations citations 中 大于等于 m i d mid mid 的元素一共有 c n t cnt cnt 个。

  • 如果 c n t ≥ m i d cnt \geq mid cntmid,说明 c n t cnt cnt 指数,是满足 c i t a t i o n s citations citations 的,故 l = m i d l = mid l=mid
  • 如果 c n t ≥ m i d cnt \geq mid cntmid,说明 c n t cnt cnt 指数,不满足 c i t a t i o n s citations citations 的,故 r = m i d − 1 r = mid - 1 r=mid1

时间复杂度: O ( l o g 2 n ) O(log^2n) O(log2n)

C++代码:

class Solution {
public:int hIndex(vector<int>& citations) {int n = citations.size();int l = 0  , r = n;while(l < r){int mid = (l + r + 1) >> 1;auto it = lower_bound(citations.begin(),citations.end(),mid);int cnt = citations.end() - it;if(cnt >= mid) l = mid;else r = mid - 1;}return l;}
};
http://www.khdw.cn/news/59816.html

相关文章:

  • 有什么教做甜品的网站站长工具 seo查询
  • 软件开发工程师是程序员吗专业seo站长工具全面查询网站
  • 农业信息门户网站建设方案百度2020新版下载
  • 咸阳网站开发公司官网模板
  • 青岛专业建设网站湖南今日新闻最新头条
  • 网站banner制作中国大数据平台官网
  • 一个网站域名一年要多少钱seo关键词优化推广报价表
  • 科技服务公司网站模版青岛网站制作seo
  • 做厂房出租有那些推广网站网络舆情管理
  • dw网站建设的常用技术网店推广实训系统
  • 自己做网站的准备工作爱站网站长seo综合查询
  • 做英文网站多少钱各类资源关键词
  • 鼓楼网站seo搜索引擎优化考拉seo
  • 做设计怎么进公司网站seo技术外包公司
  • 佳木斯万达建设网站企业关键词优化公司
  • 美食网站设计论文武汉百度seo排名
  • cs如何做全屏网站搜资源
  • 为什么不用原来的网站做推广seo搜索引擎优化原理
  • 手机网站建设做竞价推广的技巧强强seo博客
  • 呼和浩特网站建设百度怎么收录自己的网站
  • wordpress主题汉化版seo成创网络
  • 淄博网站优化百度推广售后
  • 优质服务的网站设计制作宁波超值关键词优化
  • 新建网站如何推广免费网页设计制作网站
  • 哈尔滨网站建设服务公司网站页面优化内容包括哪些
  • 海南网站建设粤icp备企业查询系统
  • 张家港网站网络优化今天最新疫情情况
  • 自媒体平台收益东莞seo技术
  • 中山企业手机网站建设中山seo关键词
  • 哪个跨境电商网站做的最好爱站seo工具包官网