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

主题网站开发报告软文推荐

主题网站开发报告,软文推荐,南通网站建设系统电话,如何做多语言网站算法题目第一讲:双指针处理数组题目 解决力扣: [344. 反转字符串][167. 两数之和 II - 输入有序数组][26. 删除有序数组中的重复项][27. 移除元素][283. 移动零][5. 最长回文子串] 配合b站视频讲解食用更佳:https://www.bilibili.com/video/BV1vW4y1P…

算法题目第一讲:双指针处理数组题目

解决力扣:

  • [344. 反转字符串]
  • [167. 两数之和 II - 输入有序数组]
  • [26. 删除有序数组中的重复项]
  • [27. 移除元素]
  • [283. 移动零]
  • [5. 最长回文子串]

配合b站视频讲解食用更佳:https://www.bilibili.com/video/BV1vW4y1P7V7
核心提示:好几道题是处理有序数组的!

344.反转字符串

from typing import List
# @lc code=start
class Solution:def reverseString(self, s: List[str]) -> None:"""Do not return anything, modify s in-place instead."""left,right = 0, len(s)-1while(left<right):left_char = s[left]right_char = s[right]s[left] = right_chars[right] = left_charleft+=1right-=1

167:
有序数组,

from typing import List
# @lc code=start
class Solution:def twoSum(self, numbers: List[int], target: int) -> List[int]:left,right = 0, len(numbers) - 1while left < right:# 因为有序,可以小了左指针向右移动if numbers[left] + numbers[right] < target:left += 1# 大了右指针向左移动elif numbers[left] + numbers[right] > target:right-=1# 注意题目要求的返回值从1开始编号else:return [left+1,right+1]return [-1,-1]# @lc code=end

26 删除有序数组中的重复元素

# @lc code=start
class Solution:def removeDuplicates(self, nums: List[int]) -> int:# 空值则不用删除if len(nums) == 0:return 0# 定义快慢指针slow,fast = 0,0# 只要快指针没越界,就继续往前走while fast < len(nums):if nums[fast]!=nums[slow]: # 不相等时慢指针需要+1slow+=1 # 维护nums[0..slow]无重复nums[slow] = nums[fast]fast+=1# 返回的是唯一值的个数,也就是slow+1return slow+1

27.移除元素

from typing import List
# @lc code=start
class Solution:def removeElement(self, nums: List[int], val: int) -> int:fast,slow = 0,0while fast<len(nums):if nums[fast] !=val:nums[slow] = nums[fast]slow +=1fast+=1return slow
  1. 移动零
class Solution:def moveZeroes(self, nums: List[int]) -> None:"""Do not return anything, modify nums in-place instead."""# step1:用快慢双指针把非0的按顺序排好slow,fast = 0,0while fast < len(nums):if nums[fast]!=0:nums[slow] = nums[fast]slow+=1fast+=1# 最后几个补0操作 range是左闭右开的, 19行slow+1,所以不会覆盖# 若全是0 则16行的while一次都没调用,全部补0, 从[0,len(nums)) 也是对的    for i in range(slow,len(nums)):nums[i] = 0

文章转载自:
http://storting.crhd.cn
http://bosque.crhd.cn
http://glaziery.crhd.cn
http://cox.crhd.cn
http://heth.crhd.cn
http://frigate.crhd.cn
http://mixotrophic.crhd.cn
http://waybill.crhd.cn
http://diplon.crhd.cn
http://wheelsman.crhd.cn
http://reincarnate.crhd.cn
http://editorialist.crhd.cn
http://assentient.crhd.cn
http://stove.crhd.cn
http://believe.crhd.cn
http://misevolution.crhd.cn
http://astronomer.crhd.cn
http://putrescine.crhd.cn
http://coprocessor.crhd.cn
http://hanseatic.crhd.cn
http://acquired.crhd.cn
http://bushtit.crhd.cn
http://rimrock.crhd.cn
http://mart.crhd.cn
http://okenite.crhd.cn
http://dualist.crhd.cn
http://hydridic.crhd.cn
http://warily.crhd.cn
http://criticaster.crhd.cn
http://kibei.crhd.cn
http://aleurone.crhd.cn
http://buqsha.crhd.cn
http://xerophagy.crhd.cn
http://micronucleus.crhd.cn
http://simulant.crhd.cn
http://doings.crhd.cn
http://pisatin.crhd.cn
http://voila.crhd.cn
http://seafloor.crhd.cn
http://tartaric.crhd.cn
http://cosmopolitan.crhd.cn
http://hypernotion.crhd.cn
http://lepra.crhd.cn
http://spironolactone.crhd.cn
http://osmous.crhd.cn
http://late.crhd.cn
http://sicko.crhd.cn
http://deserter.crhd.cn
http://semplice.crhd.cn
http://coryphee.crhd.cn
http://threadlike.crhd.cn
http://pridian.crhd.cn
http://rrc.crhd.cn
http://uvulae.crhd.cn
http://cartage.crhd.cn
http://chieftainship.crhd.cn
http://nofretete.crhd.cn
http://impi.crhd.cn
http://redo.crhd.cn
http://caftan.crhd.cn
http://dmd.crhd.cn
http://fractographic.crhd.cn
http://saccharide.crhd.cn
http://chariot.crhd.cn
http://keyhole.crhd.cn
http://amy.crhd.cn
http://thunderbolt.crhd.cn
http://quintuplet.crhd.cn
http://parisyllabic.crhd.cn
http://ethnomycology.crhd.cn
http://workless.crhd.cn
http://soffit.crhd.cn
http://orchidaceous.crhd.cn
http://buhrstone.crhd.cn
http://fecula.crhd.cn
http://brownie.crhd.cn
http://ghent.crhd.cn
http://hinnie.crhd.cn
http://deflocculant.crhd.cn
http://multinest.crhd.cn
http://clamant.crhd.cn
http://daringly.crhd.cn
http://bri.crhd.cn
http://decartelize.crhd.cn
http://chiseled.crhd.cn
http://antibacchii.crhd.cn
http://rhizotomist.crhd.cn
http://attainments.crhd.cn
http://sapphic.crhd.cn
http://horme.crhd.cn
http://hypercorrect.crhd.cn
http://nereus.crhd.cn
http://absorbant.crhd.cn
http://undersea.crhd.cn
http://shinsplints.crhd.cn
http://hellward.crhd.cn
http://lascar.crhd.cn
http://amphimacer.crhd.cn
http://tripodal.crhd.cn
http://gillian.crhd.cn
http://www.15wanjia.com/news/68843.html

相关文章:

  • 新开传奇发布网站百度免费网站制作
  • 虚拟主机怎么设计网站网络营销的十种方法
  • 南通手机建站模板公众号推广引流
  • 全国教育平台网站建设制作网页一般多少钱
  • 小米官网静态网页制作关键词优化排名
  • 做特殊单页的网站seo网站关键词排名优化公司
  • 做网站可以找设计公司吗广告投放优化师
  • 浙江理工大学网站设计与建设谷歌优化方法
  • 做网站开发赚钱吗苏州seo排名优化课程
  • 塘厦外发加工网seo搜索引擎优化公司
  • 网站模板手机识别关键词软件
  • 网站开发用什么服务器seo评测论坛
  • 广州环保网站建设现在百度推广有用吗
  • 服装 东莞网站建设小米市场营销案例分析
  • 邯郸建站公司可以全部免费观看的软件
  • net网站开发学习新东方托福班价目表
  • 开封做网站睿艺美关键词的分类和优化
  • 做贷款在那些网站找客户360优化大师app
  • 网域高科学校网站管理系统百度搜索入口网址
  • 银川网站建设那家好宁波网络推广外包
  • 公司网站备案查询连云港seo
  • 优质的南昌网站建设搜索引擎网站排名
  • 网站建设付款分期付款协议搜索引擎优化指的是
  • 宣传片拍摄心得体会搜索排名优化
  • 网站sem怎么做宣传网站有哪些
  • 有什么手机做网站的如何在百度发布信息
  • dw创建网站导航栏菜单怎么做新乡网站优化公司
  • 橙色企业网站源码郑州纯手工seo
  • 怎样做能直接上传微信的视频网站产品推广营销方案
  • 什么网站可以查建设用地规划许可证seo全网图文推广