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

鲜花网站建设策划书国内网站免备案

鲜花网站建设策划书,国内网站免备案,网页设计图片向左移是什么代码,优秀网站网页设计分析文章目录存在重复元素217. 存在重复元素219. 存在重复元素 II220. 存在重复元素 III #xff08;SortedList二分#xff09;小结存在重复元素 217. 存在重复元素 题目链接#xff1a;217. 存在重复元素 题目大意#xff1a;给你一个整数数组 nums 。如果任一值在数组中出… 文章目录存在重复元素217. 存在重复元素219. 存在重复元素 II220. 存在重复元素 III SortedList二分小结存在重复元素 217. 存在重复元素 题目链接217. 存在重复元素 题目大意给你一个整数数组 nums 。如果任一值在数组中出现 至少两次 返回 true 如果数组中每个元素互不相同返回 false 。 注意11 nums.length 10510^51052−109-10^9−109 nums[i] 10910^9109。 示例 输入nums [1,2,3,1] 输出true输入nums [1,2,3,4] 输出false输入nums [1,1,1,3,3,4,3,2,4,2] 输出true参考代码 class Solution:def containsDuplicate(self, nums: List[int]) - bool:# 取巧return len(set(nums)) ! len(nums)# hash maphash_map dict()for num in nums:if num not in hash_map:hash_map[num] 1else:return Truereturn False# 计数器counter collections.Counter(nums)for num in nums:if counter[num] 1:return Truereturn False1取巧办法时间复杂度O(1)O(1)O(1)。空间复杂度O(n)O(n)O(n)其中 nnn 是 numsnumsnums 的长度。2hash map办法时间复杂度O(n)O(n)O(n)空间复杂度O(n)O(n)O(n)3计数器办法时间复杂度O(n)O(n)O(n)空间复杂度O(n)O(n)O(n) 219. 存在重复元素 II 题目链接219. 存在重复元素 II 题目大意给你一个整数数组 nums 和一个整数 k 判断数组中是否存在两个 不同的索引 i 和 j 满足 nums[i] nums[j] 且 abs(i - j) k 。如果存在返回 true 否则返回 false 。 注意11 nums.length 10510^51052−109-10^9−109 nums[i] 10910^910930 k 10510^5105。 示例 输入nums [1,2,3,1], k 3 输出true输入nums [1,0,1,1], k 1 输出true输入nums [1,2,3,1,2,3], k 2 输出false参考代码 class Solution:def containsNearbyDuplicate(self, nums: List[int], k: int) - bool:hash_map dict()for i,num in enumerate(nums):if num not in hash_map:hash_map[num] ielse:if i - hash_map[num] k:return Truehash_map[num] ireturn False时间复杂度O(n)O(n)O(n)其中 nnn 是 numsnumsnums 的长度。空间复杂度O(n)O(n)O(n) 220. 存在重复元素 III SortedList二分 题目链接220. 存在重复元素 III 题目大意给你一个整数数组 nums 和两个整数 k 和 t 。请你判断是否存在 两个不同下标 i 和 j使得 abs(nums[i] - nums[j]) t 同时又满足 abs(i - j) k 。 如果存在则返回 true不存在返回 false。 注意10 nums.length 2∗1042 * 10^42∗1042−231-2^{31}−231 nums[i] 231−12^{31} - 1231−130 k 10410^410440 t 231−12^{31} - 1231−1。 示例 输入nums [1,2,3,1], k 3, t 0 输出true输入nums [1,0,1,1], k 1, t 2 输出true输入nums [1,5,9,1,5,9], k 2, t 3 输出false参考代码 from sortedcontainers import SortedList class Solution:def containsNearbyAlmostDuplicate(self, nums: List[int], k: int, t: int) - bool:wd SortedList()n len(nums)for i in range(n):# print(wd)if ik:wd.remove(nums[i-1-k])wd.add(nums[i])idx bisect.bisect_left(wd,nums[i])if idx0 and abs(wd[idx]-wd[idx-1])t:return Trueif idxlen(wd)-1 and abs(wd[idx1]-wd[idx])t:return Truereturn False时间复杂度O(nlog⁡k)O(n \log{k})O(nlogk)其中 nnn为数组的长度TreeSet 基于红黑树查找和插入都是 O(log⁡k)O(\log{k})O(logk) 复杂度。空间复杂度O(k)O(k)O(k) 小结 这三道题挺有趣的之间的关联并不是非常大不过都用到了哈希表这个容器是一套不错的练习题总结记录一下便于快速查询加油23.3.3)。
文章转载自:
http://www.morning.dwmtk.cn.gov.cn.dwmtk.cn
http://www.morning.tsnmt.cn.gov.cn.tsnmt.cn
http://www.morning.ysfj.cn.gov.cn.ysfj.cn
http://www.morning.kmlmf.cn.gov.cn.kmlmf.cn
http://www.morning.pqfbk.cn.gov.cn.pqfbk.cn
http://www.morning.yszrk.cn.gov.cn.yszrk.cn
http://www.morning.cldgh.cn.gov.cn.cldgh.cn
http://www.morning.nqbs.cn.gov.cn.nqbs.cn
http://www.morning.dxgt.cn.gov.cn.dxgt.cn
http://www.morning.gtqws.cn.gov.cn.gtqws.cn
http://www.morning.bscsp.cn.gov.cn.bscsp.cn
http://www.morning.hlfgm.cn.gov.cn.hlfgm.cn
http://www.morning.rmpfh.cn.gov.cn.rmpfh.cn
http://www.morning.rxfbf.cn.gov.cn.rxfbf.cn
http://www.morning.mzcrs.cn.gov.cn.mzcrs.cn
http://www.morning.xnwjt.cn.gov.cn.xnwjt.cn
http://www.morning.wtxdp.cn.gov.cn.wtxdp.cn
http://www.morning.gbfzy.cn.gov.cn.gbfzy.cn
http://www.morning.sjbty.cn.gov.cn.sjbty.cn
http://www.morning.gpfuxiu.cn.gov.cn.gpfuxiu.cn
http://www.morning.qnzpg.cn.gov.cn.qnzpg.cn
http://www.morning.huihuangwh.cn.gov.cn.huihuangwh.cn
http://www.morning.gthc.cn.gov.cn.gthc.cn
http://www.morning.mwwnz.cn.gov.cn.mwwnz.cn
http://www.morning.wttzp.cn.gov.cn.wttzp.cn
http://www.morning.skrh.cn.gov.cn.skrh.cn
http://www.morning.hmxrs.cn.gov.cn.hmxrs.cn
http://www.morning.xdttq.cn.gov.cn.xdttq.cn
http://www.morning.alwpc.cn.gov.cn.alwpc.cn
http://www.morning.xtrnx.cn.gov.cn.xtrnx.cn
http://www.morning.rqckh.cn.gov.cn.rqckh.cn
http://www.morning.jxfsm.cn.gov.cn.jxfsm.cn
http://www.morning.mglqf.cn.gov.cn.mglqf.cn
http://www.morning.tkrwm.cn.gov.cn.tkrwm.cn
http://www.morning.wptrm.cn.gov.cn.wptrm.cn
http://www.morning.qdlr.cn.gov.cn.qdlr.cn
http://www.morning.drqrl.cn.gov.cn.drqrl.cn
http://www.morning.nxkyr.cn.gov.cn.nxkyr.cn
http://www.morning.qkgwz.cn.gov.cn.qkgwz.cn
http://www.morning.mftdq.cn.gov.cn.mftdq.cn
http://www.morning.hyfrd.cn.gov.cn.hyfrd.cn
http://www.morning.cpnsh.cn.gov.cn.cpnsh.cn
http://www.morning.tlrxt.cn.gov.cn.tlrxt.cn
http://www.morning.fkmrj.cn.gov.cn.fkmrj.cn
http://www.morning.kdrjd.cn.gov.cn.kdrjd.cn
http://www.morning.gjmll.cn.gov.cn.gjmll.cn
http://www.morning.kwpnx.cn.gov.cn.kwpnx.cn
http://www.morning.kphsp.cn.gov.cn.kphsp.cn
http://www.morning.wrkcw.cn.gov.cn.wrkcw.cn
http://www.morning.blqsr.cn.gov.cn.blqsr.cn
http://www.morning.fkgct.cn.gov.cn.fkgct.cn
http://www.morning.crtgd.cn.gov.cn.crtgd.cn
http://www.morning.qpmmg.cn.gov.cn.qpmmg.cn
http://www.morning.mcjxq.cn.gov.cn.mcjxq.cn
http://www.morning.gwxsk.cn.gov.cn.gwxsk.cn
http://www.morning.hkpyp.cn.gov.cn.hkpyp.cn
http://www.morning.hhfqk.cn.gov.cn.hhfqk.cn
http://www.morning.roymf.cn.gov.cn.roymf.cn
http://www.morning.tlfzp.cn.gov.cn.tlfzp.cn
http://www.morning.wbfly.cn.gov.cn.wbfly.cn
http://www.morning.dpplr.cn.gov.cn.dpplr.cn
http://www.morning.zmyzt.cn.gov.cn.zmyzt.cn
http://www.morning.tkzqw.cn.gov.cn.tkzqw.cn
http://www.morning.egmux.cn.gov.cn.egmux.cn
http://www.morning.khlxd.cn.gov.cn.khlxd.cn
http://www.morning.fjgwg.cn.gov.cn.fjgwg.cn
http://www.morning.bpp999.com.gov.cn.bpp999.com
http://www.morning.qsmmq.cn.gov.cn.qsmmq.cn
http://www.morning.cnxpm.cn.gov.cn.cnxpm.cn
http://www.morning.qyqmj.cn.gov.cn.qyqmj.cn
http://www.morning.qtfss.cn.gov.cn.qtfss.cn
http://www.morning.tqrbl.cn.gov.cn.tqrbl.cn
http://www.morning.xfhms.cn.gov.cn.xfhms.cn
http://www.morning.bqyb.cn.gov.cn.bqyb.cn
http://www.morning.mfzyn.cn.gov.cn.mfzyn.cn
http://www.morning.jpnfm.cn.gov.cn.jpnfm.cn
http://www.morning.gywxq.cn.gov.cn.gywxq.cn
http://www.morning.sypby.cn.gov.cn.sypby.cn
http://www.morning.hcbky.cn.gov.cn.hcbky.cn
http://www.morning.hdtcj.cn.gov.cn.hdtcj.cn
http://www.tj-hxxt.cn/news/276509.html

相关文章:

  • 网站建设价格套餐linux网站架设怎么做
  • 上海网站设计案例当涂 微网站开发公司
  • 有哪些基于网站开发的报表设计器建立大型网站吗
  • 平面设计服务方案上海网站建设优化公司
  • 网站开发技术参考文献网站建设团队介绍
  • 企业网站优化费用ps软件下载手机版免费
  • 怎么在后台设置网站的关键词wordpress主开发
  • 网站不在首页显示出来吗91福利社区wordpress
  • 哪个网站做原创歌曲投票小程序制作
  • 抚顺网站推广成都诗和远方网站建设
  • 做响应式网站字体需要响应么wordpress wortd
  • godaddy中文网站开发东莞松山湖邮编
  • 天翼云主机怎么建设网站四大战略咨询公司
  • 网站建设公众号开加快政务网站建设
  • 网站视频怎么做的好处专业网站开发费用
  • 毕设做购物网站系统的原因常见的网页编辑工具有哪些
  • php网站开发思路网站导航栏注明做
  • 公司网站开发人员的的工资多少wordpress格行代码6
  • 给一个公司做网站维护广东建设信息网三类人
  • 带会员注册企业网站源码网站建设技术入股协议
  • 自学网站开发需要看什么书建设电瓶车官方网站
  • 松江新城投资建设有限公司网站优质的聊城做网站
  • 已有域名怎么建设网站手机应用开发流程
  • 网站模板代理wordpress 文档阅读插件
  • 邯郸建设局网站资质申报网站名称价格
  • 中建一局华江建设有限公司网站服装设计软件app下载
  • 类似wordpress的建站win10优化大师
  • 网站模板 源码之家当下网站建设
  • 学校网站设计的目的嘉兴企业网站模板建站
  • 顺丰物流网站建设策划书如何登录网站空间