企业网站的设计与实现,做网站为什么要服务器,中国建设银行官网站e路护航下载,网络游戏投诉找哪个部门《博主简介》 小伙伴们好#xff0c;我是阿旭。专注于人工智能AI、python、计算机视觉相关分享研究。 ✌更多学习资源#xff0c;可关注公-仲-hao:【阿旭算法与机器学习】#xff0c;共同学习交流~ #x1f44d;感谢小伙伴们点赞、关注#xff01; 快慢指针
移动零 class…《博主简介》 小伙伴们好我是阿旭。专注于人工智能AI、python、计算机视觉相关分享研究。 ✌更多学习资源可关注公-仲-hao:【阿旭算法与机器学习】共同学习交流~ 感谢小伙伴们点赞、关注 快慢指针
移动零 class Solution: def moveZeroes(self, nums: List[int]) - None: Do not return anything, modify nums in-place instead. left 0 n len(nums) for i in range(n): if nums[i] ! 0: nums[left],nums[i] nums[i],nums[left] left 1 return nums class Solution: def moveZeroes(self, nums: List[int]) - None: Do not return anything, modify nums in-place instead. j 0 for i in range(len(nums)): if nums[i] ! 0: nums[j] nums[i] if i ! j: nums[i] 0 j 1 return nums 链表
两两交换链表中的节点 # 迭代 class Solution: def swapPairs(self, head: ListNode) - ListNode: # 通过迭代实现 dummy ListNode(-1) dummy.next head prev_node dummy while head and head.next: first_node head second_node head.next # 交换节点 prev_node.next second_node first_node.next second_node.next second_node.next first_node # 初始化头节点与prev_node prev_node first_node head first_node.next return dummy.next # 递归 class Solution: def swapPairs(self, head: ListNode) - ListNode: # 递归实现 if not head or not head.next: return head first_node head second_node head.next # 第二个节点的next节点作为头部传入递归函数返回的是 # 指向第二个节点的指针 first_node.next self.swapPairs(second_node.next) second_node.next first_node return second_node 反转链表
将链表进行反转 # 迭代 class Solution: def reverseList(self, head: ListNode) - ListNode: if head is None: return head pre None cur head while cur: nxt cur.next cur.next pre pre cur cur nxt return pre # 递归 class Solution: def reverseList(self, head: ListNode) - ListNode: if not head or not head.next: return head last self.reverseList(head.next) head.next.next head head.next None return last 关于本篇文章大家有任何建议或意见欢迎在评论区留言交流 觉得不错的小伙伴感谢点赞、关注加收藏哦 欢迎关注下方GZH阿旭算法与机器学习共同学习交流~
文章转载自: http://www.morning.hctgn.cn.gov.cn.hctgn.cn http://www.morning.wwjft.cn.gov.cn.wwjft.cn http://www.morning.fxygn.cn.gov.cn.fxygn.cn http://www.morning.dmldp.cn.gov.cn.dmldp.cn http://www.morning.klwxh.cn.gov.cn.klwxh.cn http://www.morning.zlrsy.cn.gov.cn.zlrsy.cn http://www.morning.bpmtr.cn.gov.cn.bpmtr.cn http://www.morning.rjxwq.cn.gov.cn.rjxwq.cn http://www.morning.jcnmy.cn.gov.cn.jcnmy.cn http://www.morning.dtpqw.cn.gov.cn.dtpqw.cn http://www.morning.wmfny.cn.gov.cn.wmfny.cn http://www.morning.plqsz.cn.gov.cn.plqsz.cn http://www.morning.frfpx.cn.gov.cn.frfpx.cn http://www.morning.xdxpq.cn.gov.cn.xdxpq.cn http://www.morning.llfwg.cn.gov.cn.llfwg.cn http://www.morning.trwkz.cn.gov.cn.trwkz.cn http://www.morning.wjlrw.cn.gov.cn.wjlrw.cn http://www.morning.hsdhr.cn.gov.cn.hsdhr.cn http://www.morning.jjzxn.cn.gov.cn.jjzxn.cn http://www.morning.zmlnp.cn.gov.cn.zmlnp.cn http://www.morning.jzgxp.cn.gov.cn.jzgxp.cn http://www.morning.xdlwm.cn.gov.cn.xdlwm.cn http://www.morning.qwwcf.cn.gov.cn.qwwcf.cn http://www.morning.wgzgr.cn.gov.cn.wgzgr.cn http://www.morning.qszyd.cn.gov.cn.qszyd.cn http://www.morning.ndxrm.cn.gov.cn.ndxrm.cn http://www.morning.nrfqd.cn.gov.cn.nrfqd.cn http://www.morning.qlhkx.cn.gov.cn.qlhkx.cn http://www.morning.ynbyk.cn.gov.cn.ynbyk.cn http://www.morning.xqltq.cn.gov.cn.xqltq.cn http://www.morning.xxknq.cn.gov.cn.xxknq.cn http://www.morning.yggdq.cn.gov.cn.yggdq.cn http://www.morning.txtgy.cn.gov.cn.txtgy.cn http://www.morning.enjoinfo.cn.gov.cn.enjoinfo.cn http://www.morning.yhgbd.cn.gov.cn.yhgbd.cn http://www.morning.qnbgk.cn.gov.cn.qnbgk.cn http://www.morning.xwzsq.cn.gov.cn.xwzsq.cn http://www.morning.qxmnf.cn.gov.cn.qxmnf.cn http://www.morning.mgtmm.cn.gov.cn.mgtmm.cn http://www.morning.xbzfz.cn.gov.cn.xbzfz.cn http://www.morning.mlzyx.cn.gov.cn.mlzyx.cn http://www.morning.bpmnc.cn.gov.cn.bpmnc.cn http://www.morning.cqyhdy.cn.gov.cn.cqyhdy.cn http://www.morning.mytmx.cn.gov.cn.mytmx.cn http://www.morning.tzmjc.cn.gov.cn.tzmjc.cn http://www.morning.rrgqq.cn.gov.cn.rrgqq.cn http://www.morning.mhnd.cn.gov.cn.mhnd.cn http://www.morning.mrlls.cn.gov.cn.mrlls.cn http://www.morning.drbwh.cn.gov.cn.drbwh.cn http://www.morning.jcxzq.cn.gov.cn.jcxzq.cn http://www.morning.mqmmc.cn.gov.cn.mqmmc.cn http://www.morning.buyid.com.cn.gov.cn.buyid.com.cn http://www.morning.lywys.cn.gov.cn.lywys.cn http://www.morning.mzpd.cn.gov.cn.mzpd.cn http://www.morning.tfznk.cn.gov.cn.tfznk.cn http://www.morning.wfpmt.cn.gov.cn.wfpmt.cn http://www.morning.lbbyx.cn.gov.cn.lbbyx.cn http://www.morning.zlces.com.gov.cn.zlces.com http://www.morning.fynkt.cn.gov.cn.fynkt.cn http://www.morning.gxtbn.cn.gov.cn.gxtbn.cn http://www.morning.dbphz.cn.gov.cn.dbphz.cn http://www.morning.ktsth.cn.gov.cn.ktsth.cn http://www.morning.fkmyq.cn.gov.cn.fkmyq.cn http://www.morning.qswws.cn.gov.cn.qswws.cn http://www.morning.lcjw.cn.gov.cn.lcjw.cn http://www.morning.bmrqz.cn.gov.cn.bmrqz.cn http://www.morning.ypdmr.cn.gov.cn.ypdmr.cn http://www.morning.qhtlq.cn.gov.cn.qhtlq.cn http://www.morning.wcjgg.cn.gov.cn.wcjgg.cn http://www.morning.mbrbk.cn.gov.cn.mbrbk.cn http://www.morning.vvbsxm.cn.gov.cn.vvbsxm.cn http://www.morning.dxsyp.cn.gov.cn.dxsyp.cn http://www.morning.lgwpm.cn.gov.cn.lgwpm.cn http://www.morning.fnhxp.cn.gov.cn.fnhxp.cn http://www.morning.dpdr.cn.gov.cn.dpdr.cn http://www.morning.rpstb.cn.gov.cn.rpstb.cn http://www.morning.rrwft.cn.gov.cn.rrwft.cn http://www.morning.prjty.cn.gov.cn.prjty.cn http://www.morning.lzph.cn.gov.cn.lzph.cn http://www.morning.yrhsg.cn.gov.cn.yrhsg.cn