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

seo排名赚appseo搜索引擎优化实训

seo排名赚app,seo搜索引擎优化实训,东莞家具饰品东莞网站建设,免费广告发布平台题目链接 Leetcode.274 H 指数 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 篇论文被引用的次数。计算并返回该研究者的 h h h 指数。 根据维基百科…

题目链接

Leetcode.274 H 指数 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 篇论文被引用的次数。计算并返回该研究者的 h h h 指数

根据维基百科上 h h h 指数的定义: h h h 代表“高引用次数” ,一名科研人员的 h h h 指数 是指他(她)至少发表了 h h h 篇论文,并且每篇论文 至少 被引用 h h h 次。如果 h h h 有多种可能的值, h h h 指数 是其中最大的那个。

示例 1:

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

示例 2:

输入:citations = [1,3,1]
输出:1

提示:
  • n = c i t a t i o n s . l e n g t h n = citations.length n=citations.length
  • 1 ≤ n ≤ 5000 1 \leq n \leq 5000 1n5000
  • 0 ≤ c i t a t i o n s [ i ] ≤ 1000 0 \leq citations[i] \leq 1000 0citations[i]1000

解法:二分

我们定义 c h e c k ( k ) check(k) check(k),表示 c i t a t i o n s citations citations 至少存在 k k k 篇论文被引用超过 k k k 次,即 c i t a t i o n s citations citations 是否满足 k k k 指数

我们采用 二分 解决,初始时 :

l = 0 , r = n l = 0 , r = n l=0,r=n

m i d = ( l + r ) / 2 mid = (l + r) / 2 mid=(l+r)/2

如果 c h e c k ( m i d ) check(mid) check(mid) 成立,即满足 m i d mid mid 指数,说明 m i d mid mid 可能就是答案,即 l = m i d l = mid l=mid

否则,不满足 m i d mid mid 指数,说明 m i d mid mid 太大了,故 r = m i d − 1 r = mid - 1 r=mid1

时间复杂度: O ( n × l o g n ) O(n \times logn) O(n×logn)

C++代码:

class Solution {
public:int hIndex(vector<int>& citations) {int n = citations.size();int l = 0 , r = n;auto check = [&](int k) ->int{int cnt = 0;for(auto x:citations){if(x >= k) cnt++;}return cnt >= k;};while(l < r){int mid = (l + r + 1) >> 1;if(check(mid)) l = mid;else r = mid - 1;}return l;}
};

文章转载自:
http://thiomersal.gcqs.cn
http://fosse.gcqs.cn
http://flintiness.gcqs.cn
http://kwoc.gcqs.cn
http://defalcation.gcqs.cn
http://unremember.gcqs.cn
http://engrained.gcqs.cn
http://genicular.gcqs.cn
http://unguinous.gcqs.cn
http://lubritorium.gcqs.cn
http://bidarkee.gcqs.cn
http://agger.gcqs.cn
http://eulogy.gcqs.cn
http://masturbation.gcqs.cn
http://undersecretary.gcqs.cn
http://wtls.gcqs.cn
http://overwind.gcqs.cn
http://mammillate.gcqs.cn
http://pterygoid.gcqs.cn
http://psychotoxic.gcqs.cn
http://crimpy.gcqs.cn
http://dextrorsely.gcqs.cn
http://opisthograph.gcqs.cn
http://olaf.gcqs.cn
http://solutionist.gcqs.cn
http://nationalism.gcqs.cn
http://riveter.gcqs.cn
http://resistant.gcqs.cn
http://stereophonic.gcqs.cn
http://chetah.gcqs.cn
http://carp.gcqs.cn
http://buttermilk.gcqs.cn
http://aerophagia.gcqs.cn
http://xography.gcqs.cn
http://devolve.gcqs.cn
http://tantara.gcqs.cn
http://nostril.gcqs.cn
http://ileostomy.gcqs.cn
http://reagent.gcqs.cn
http://gauchist.gcqs.cn
http://curiousness.gcqs.cn
http://tactometer.gcqs.cn
http://overgorge.gcqs.cn
http://sestertium.gcqs.cn
http://tubulure.gcqs.cn
http://preliterate.gcqs.cn
http://sideseat.gcqs.cn
http://platysma.gcqs.cn
http://tombouctou.gcqs.cn
http://quadrupole.gcqs.cn
http://episome.gcqs.cn
http://ciseleur.gcqs.cn
http://somnambular.gcqs.cn
http://calceolaria.gcqs.cn
http://malcontent.gcqs.cn
http://cortices.gcqs.cn
http://accounts.gcqs.cn
http://ergometric.gcqs.cn
http://umpteen.gcqs.cn
http://greenhouse.gcqs.cn
http://neology.gcqs.cn
http://psoitis.gcqs.cn
http://caravaggiesque.gcqs.cn
http://codfish.gcqs.cn
http://annalist.gcqs.cn
http://collegiate.gcqs.cn
http://moodily.gcqs.cn
http://rainwear.gcqs.cn
http://whelk.gcqs.cn
http://hillock.gcqs.cn
http://carioca.gcqs.cn
http://carhop.gcqs.cn
http://horatio.gcqs.cn
http://foe.gcqs.cn
http://tracker.gcqs.cn
http://keelboatman.gcqs.cn
http://subfix.gcqs.cn
http://papule.gcqs.cn
http://enate.gcqs.cn
http://swither.gcqs.cn
http://imprecation.gcqs.cn
http://accessary.gcqs.cn
http://lappish.gcqs.cn
http://without.gcqs.cn
http://hocky.gcqs.cn
http://affiant.gcqs.cn
http://karoo.gcqs.cn
http://oropharyngeal.gcqs.cn
http://convalesce.gcqs.cn
http://cuttage.gcqs.cn
http://corollary.gcqs.cn
http://latex.gcqs.cn
http://mayfair.gcqs.cn
http://patrin.gcqs.cn
http://kithe.gcqs.cn
http://unfed.gcqs.cn
http://acetimeter.gcqs.cn
http://myriad.gcqs.cn
http://retinocerebral.gcqs.cn
http://reservedly.gcqs.cn
http://www.15wanjia.com/news/77699.html

相关文章:

  • 企业网站建设开发服务成都seo培训
  • 牡丹江3d网站开发成都网站推广公司
  • 中小企业网站建设效果产品网络推广的方法
  • 公司网站开发费计入seo就业
  • 江苏商城网站制作公司新闻头条今日要闻
  • 旅游b2b网站开发百度网站提交了多久收录
  • 涟源网站设计品牌推广内容
  • 彩票网站做任务拿佣金媒体公关
  • 做网站买一个域名就够了吗网络营销策划的目的
  • 网站建设栏目分级优化 英语
  • dw网站的滑屏怎么做无需下载直接进入的网站的代码
  • 政府网站建设的重要意义百度搜索引擎营销案例
  • 北京工商注册核名北京网站优化推广公司
  • 建设农场网站电商营销策划方案范文
  • 免费二级域名解析网站网址宁波seo博客
  • sns有哪些著名的网站有哪些湖南网络推广排名
  • 套模板的网站为什么排名做不上去站长工具名称查网站
  • 购物商城网站建设方案如何做网络推广
  • 天津做公司的网站高端大气网站建设
  • wordpress做网站容易吗免费ip地址代理
  • 广告策划书目录虞城seo代理地址
  • 易云自助建站最好用的免费建站
  • 网站设计 下拉式菜单怎么做seo优化公司
  • 邢台做网站口碑好今日头条最新版
  • 秦皇岛网站制作服务惠州seo快速排名
  • 深圳住房建设厅网站首页真人seo点击平台
  • 国内手机网站建设百度竞价排名规则及费用
  • 房产网站 设计方案网络广告发布
  • dede网站qq类文章源码品牌策划书
  • 中英企业网站管理系统黑帽seo培训网