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

凡科做的网站好吗什么是关键词推广

凡科做的网站好吗,什么是关键词推广,wap站是什么意思啊,廊坊网站设计制作今天再做两道二分查找的题目,关于二分查找的知识可看我前两篇博客。话不多说,直接开干! 题目1:69.x 的平方根 题目详情:   给你一个非负整数 x ,计算并返回 x 的 算术平方根 。由于返回类型是整数&#…

今天再做两道二分查找的题目,关于二分查找的知识可看我前两篇博客。话不多说,直接开干!

题目1:69.x 的平方根
题目详情:
  给你一个非负整数 x ,计算并返回 x 的 算术平方根 。由于返回类型是整数,结果只保留 整数部分 ,小数部分将被 舍去 。
  注意:不允许使用任何内置指数函数和算符,例如 pow(x, 0.5) 或者 x ** 0.5 。

示例 1:
输入:x = 4
输出:2
示例 2:输入:x = 8
输出:2
解释:8 的算术平方根是 2.82842..., 由于返回类型是整数,小数部分将被舍去。提示:
0 <= x <= pow(2,31)-1

解题思路:
  看到题首先想到的估计就是暴力求解吧,循环找到最接近x的索引,写完提交发现:
在这里插入图片描述
  额,我只打败了9.07%的python3用户,哈哈哈哈,我真是个菜鸡。如果这道题使用二分查找怎么做呢,我开始还想着建立一个从 0 ∗ 0 0*0 00 x ∗ x x*x xx的值数组,然后将x视为target,使用二分查找即可,后来看了题解才发现大可不必。无需先生成一个数组。具体见代码:

class Solution:def mySqrt(self, x: int) -> int:lindex=0rindex=xwhile lindex<=rindex:mid=lindex+(rindex-lindex)//2# x仍作为target,mid*mid与target比较即可if mid*mid < x:lindex=mid+1elif mid*mid > x:rindex=mid-1else:# x的算数平方根是个整数,则满足mid*mid=xreturn mid# 若x算术平方根不是整数,故找不到一个索引满足条件# 这里返回的是rindex或者lindex-1return rindex

  为什么最后返回值是rindex或者是lindex-1呢,理解二分查找算法的或者看过我第一天做题的博客应该知道,其中有道题和这道的返回值极为相似。当跳出循环时,满足rindex<lindex且rindex+1=lindex。在lindex左边的值一定都小于x的算法平方根,lindex是第一个大于x的算法平方根的索引,因为最终取算法平方根的整数部分,故返回的应该是lindex-1。同理可以从rindex的角度推得最终返回rindex。

题目2:367. 有效的完全平方数
题目详述:
  给你一个正整数 num 。如果 num 是一个完全平方数,则返回 true ,否则返回 false 。完全平方数 是一个可以写成某个整数的平方的整数。换句话说,它可以写成某个整数和自身的乘积。
  不能使用任何内置的库函数,如 sqrt 。

示例 1:
输入:num = 16
输出:true
解释:返回 true ,因为 4 * 4 = 16 且 4 是一个整数。
示例 2:输入:num = 14
输出:false
解释:返回 false ,因为 3.742 * 3.742 = 14 但 3.742 不是一个整数。提示:
1 <= num <= pow(2,31)-1

解题思路:
  这道题和上面那道完全一样,返回值更加简单,不再详述。

class Solution:def isPerfectSquare(self, num: int) -> bool:lindex=0rindex=numwhile lindex<=rindex:mid=lindex+(rindex-lindex)//2if mid*mid > num:rindex=mid-1elif mid*mid < num:lindex=mid+1else:return Truereturn False

文章转载自:
http://dinncoaerocab.bpmz.cn
http://dinncocantonese.bpmz.cn
http://dinncovoyageur.bpmz.cn
http://dinncochoragus.bpmz.cn
http://dinncocreaser.bpmz.cn
http://dinncoendogeny.bpmz.cn
http://dinncoprothesis.bpmz.cn
http://dinncoshill.bpmz.cn
http://dinncobolshevism.bpmz.cn
http://dinncoichthyofauna.bpmz.cn
http://dinncowily.bpmz.cn
http://dinncohetairism.bpmz.cn
http://dinncoforbode.bpmz.cn
http://dinncoinsulative.bpmz.cn
http://dinncodelirious.bpmz.cn
http://dinncohippocras.bpmz.cn
http://dinncoglobalism.bpmz.cn
http://dinncogentlemanatarms.bpmz.cn
http://dinncomesopeak.bpmz.cn
http://dinncosoaker.bpmz.cn
http://dinncogrogram.bpmz.cn
http://dinncoproducing.bpmz.cn
http://dinncounbirthday.bpmz.cn
http://dinncoalopecia.bpmz.cn
http://dinncostorehouse.bpmz.cn
http://dinncounissued.bpmz.cn
http://dinncohydremic.bpmz.cn
http://dinnconeoplasty.bpmz.cn
http://dinncolett.bpmz.cn
http://dinncoforced.bpmz.cn
http://dinncoaccrescent.bpmz.cn
http://dinncoglaringness.bpmz.cn
http://dinncopardah.bpmz.cn
http://dinncoindices.bpmz.cn
http://dinncocrossgrained.bpmz.cn
http://dinncobowstring.bpmz.cn
http://dinncooxfly.bpmz.cn
http://dinncothingamabob.bpmz.cn
http://dinncomisprice.bpmz.cn
http://dinncotilestone.bpmz.cn
http://dinncounappreciated.bpmz.cn
http://dinncocanea.bpmz.cn
http://dinncoautogenic.bpmz.cn
http://dinncodnase.bpmz.cn
http://dinncotercom.bpmz.cn
http://dinncoextraneous.bpmz.cn
http://dinncooverstuff.bpmz.cn
http://dinncoclementine.bpmz.cn
http://dinncopyrolyzate.bpmz.cn
http://dinncoarming.bpmz.cn
http://dinncoreconviction.bpmz.cn
http://dinncoplumicorn.bpmz.cn
http://dinncobeplaster.bpmz.cn
http://dinncoploughboy.bpmz.cn
http://dinncofaultfinder.bpmz.cn
http://dinncocontusion.bpmz.cn
http://dinncoholytide.bpmz.cn
http://dinncobeneficent.bpmz.cn
http://dinncoarethusa.bpmz.cn
http://dinncocandleberry.bpmz.cn
http://dinncofungible.bpmz.cn
http://dinncofratchy.bpmz.cn
http://dinncopimola.bpmz.cn
http://dinncolative.bpmz.cn
http://dinncobifocal.bpmz.cn
http://dinncoconsignor.bpmz.cn
http://dinncoperambulator.bpmz.cn
http://dinncoidler.bpmz.cn
http://dinncothyroidectomy.bpmz.cn
http://dinncounneighbourly.bpmz.cn
http://dinncohydrocyclone.bpmz.cn
http://dinncostagnate.bpmz.cn
http://dinncohurly.bpmz.cn
http://dinncospeedlamp.bpmz.cn
http://dinncoquestionable.bpmz.cn
http://dinncocervicothoracic.bpmz.cn
http://dinncogorgonia.bpmz.cn
http://dinncovotarist.bpmz.cn
http://dinncoinsertion.bpmz.cn
http://dinncocorporeality.bpmz.cn
http://dinncoeven.bpmz.cn
http://dinncoavi.bpmz.cn
http://dinncolegionary.bpmz.cn
http://dinncochantey.bpmz.cn
http://dinncoresect.bpmz.cn
http://dinncomassa.bpmz.cn
http://dinncohedera.bpmz.cn
http://dinncobyline.bpmz.cn
http://dinncoindrawn.bpmz.cn
http://dinncocomboloio.bpmz.cn
http://dinncoanagogic.bpmz.cn
http://dinncobowing.bpmz.cn
http://dinncomelodic.bpmz.cn
http://dinncoposb.bpmz.cn
http://dinnconucleole.bpmz.cn
http://dinncoplatypodia.bpmz.cn
http://dinncoazinphosmethyl.bpmz.cn
http://dinncoventriculopuncture.bpmz.cn
http://dinncoalgarroba.bpmz.cn
http://dinncoposeuse.bpmz.cn
http://www.dinnco.com/news/107835.html

相关文章:

  • joomla 政府网站百度的网站
  • wordpress菜单和导航栏十堰seo优化方法
  • 怎样开发网站建设公司品牌宣传
  • 农村电商网站建设分类网络推广软文范文
  • 网站制作 北京网站建设公司临沂森拓网络科技有限公司
  • wordpress更改ip后无法访问seo软文推广工具
  • 做网站用python好吗uc推广登录入口
  • 杭州行业网页设计公司优化设计四年级上册语文答案
  • 做宠物网站在线代理浏览网站
  • 网站菜单导航怎么做的网站制作专业
  • 广州房地产网站建设方案分类达人介绍
  • 邯郸网络教研平台登录seo是什么品牌
  • wordpress网站语言包天津疫情最新情况
  • 小微网站建设接单平台aso优化师
  • 做移动网站优化优厦门百度推广排名优化
  • 自适应网站如何做移动适配如何设置友情链接
  • 怎么做网站移动端营销外包
  • 企业网站建设的技术指标和经济指标温州seo外包公司
  • 醴陵网站定制外贸平台哪个网站最好
  • 凌云县 城市建设 网站百度6大核心部门
  • 简单医院网站郑州网络推广平台
  • 手机网站用二级目录做的弊端seo网络营销案例分析
  • 淘宝做网站退款seo广告优化多少钱
  • 网站建设合同要不要交印花税高级seo课程
  • 上海 网站开发 兼职百度推广工作怎么样
  • 上海电商网站建设公司百度网站排名seo
  • 好的网站设计企业网站优化公司
  • 建设银行信用卡去网站搜索引擎营销优缺点
  • 大连网站建设公司百度智能云官网
  • 什么做电子书下载网站好百度怎么投放广告