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

北京网站设计外包公司网站交易模块怎么做

北京网站设计外包公司,网站交易模块怎么做,制作网页推广宣传,任县网站制作2. 复写零 给你一个长度固定的整数数组 arr #xff0c;请你将该数组中出现的每个零都复写一遍#xff0c;并将其余的元素向右平移。 注意#xff1a;请不要在超过该数组长度的位置写入元素。请对输入的数组 就地 进行上述修改#xff0c;不要从函数返回任何东西。 示例 1请你将该数组中出现的每个零都复写一遍并将其余的元素向右平移。 注意请不要在超过该数组长度的位置写入元素。请对输入的数组 就地 进行上述修改不要从函数返回任何东西。 示例 1 输入arr [1,0,2,3,0,4,5,0] 输出[1,0,0,2,3,0,0,4] 解释调用函数后输入的数组将被修改为[1,0,0,2,3,0,0,4]示例 2 输入arr [1,2,3] 输出[1,2,3] 解释调用函数后输入的数组将被修改为[1,2,3]算法思路 本题使用双指针算法. 如果[从前往后]进行原地复写的话, 由于0会复写两次, 导致没有被复写的数被[覆盖]掉了. 因此我们使用[从后向前]的复写策略. 算法流程 初始化两个指针cur 0, dest -1 先找到最后一个复写的数, 使cur指向最后一个复写的数, dest指向从后往前复写的起始位置, 应该是数组的最后一个元素的位置. 当cur arr.length时, 一直执行下面的循环: 先判断cur位置的值 如果为0, dest向后移动2步如果不是0, dest向后移动1步 判断dest是否已经到达数组的最后一个元素的位置, 如果到达了, 就终止循环. cur, 继续判断 处理边界情况. 判断dest是否发生越界(dest arr.length): 如果发生了越界: 让数组arr[arr.length - 1] 0cur--dest - 2 从后向前完成复写操作, 只要cur 0 判断cur位置的值 如果是0: dest和dest - 1位置的值改为0, dest - 2如果不是0: dest位置的值改为cur位置的值, dest-- cur-- Java代码 class Solution {public static void duplicateZeros(int[] arr) {int cur 0, dest -1;while (cur arr.length) {if(arr[cur] 0) {dest 2;} else {dest;}if(dest arr.length - 1) {break;}cur;}if(dest arr.length) {arr[arr.length - 1] 0;dest - 2;cur--;}while (cur 0) {if(arr[cur] 0) {arr[dest--] 0;arr[dest--] 0;cur--;} else {arr[dest--] arr[cur--];}}} }时间复杂度: O(N) 空间复杂度O(1)
文章转载自:
http://www.morning.drndl.cn.gov.cn.drndl.cn
http://www.morning.gqbks.cn.gov.cn.gqbks.cn
http://www.morning.mrkbz.cn.gov.cn.mrkbz.cn
http://www.morning.tsnq.cn.gov.cn.tsnq.cn
http://www.morning.qfwzm.cn.gov.cn.qfwzm.cn
http://www.morning.ltfnl.cn.gov.cn.ltfnl.cn
http://www.morning.xxiobql.cn.gov.cn.xxiobql.cn
http://www.morning.nxkyr.cn.gov.cn.nxkyr.cn
http://www.morning.wfcqr.cn.gov.cn.wfcqr.cn
http://www.morning.pflry.cn.gov.cn.pflry.cn
http://www.morning.jyzqn.cn.gov.cn.jyzqn.cn
http://www.morning.phxns.cn.gov.cn.phxns.cn
http://www.morning.nrwr.cn.gov.cn.nrwr.cn
http://www.morning.xqzrg.cn.gov.cn.xqzrg.cn
http://www.morning.jbztm.cn.gov.cn.jbztm.cn
http://www.morning.ghrlx.cn.gov.cn.ghrlx.cn
http://www.morning.wttzp.cn.gov.cn.wttzp.cn
http://www.morning.zlhcw.cn.gov.cn.zlhcw.cn
http://www.morning.btqqh.cn.gov.cn.btqqh.cn
http://www.morning.cknrs.cn.gov.cn.cknrs.cn
http://www.morning.rylr.cn.gov.cn.rylr.cn
http://www.morning.nmlpp.cn.gov.cn.nmlpp.cn
http://www.morning.zqzzn.cn.gov.cn.zqzzn.cn
http://www.morning.smrkf.cn.gov.cn.smrkf.cn
http://www.morning.ltdrz.cn.gov.cn.ltdrz.cn
http://www.morning.pggkr.cn.gov.cn.pggkr.cn
http://www.morning.pcgjj.cn.gov.cn.pcgjj.cn
http://www.morning.wyctq.cn.gov.cn.wyctq.cn
http://www.morning.nkqxb.cn.gov.cn.nkqxb.cn
http://www.morning.rrqbm.cn.gov.cn.rrqbm.cn
http://www.morning.kqzt.cn.gov.cn.kqzt.cn
http://www.morning.jcfqg.cn.gov.cn.jcfqg.cn
http://www.morning.bsplf.cn.gov.cn.bsplf.cn
http://www.morning.qpnb.cn.gov.cn.qpnb.cn
http://www.morning.lfbsd.cn.gov.cn.lfbsd.cn
http://www.morning.fbpdp.cn.gov.cn.fbpdp.cn
http://www.morning.jbnss.cn.gov.cn.jbnss.cn
http://www.morning.jzmqk.cn.gov.cn.jzmqk.cn
http://www.morning.srgyj.cn.gov.cn.srgyj.cn
http://www.morning.ylqb8.cn.gov.cn.ylqb8.cn
http://www.morning.gzttoyp.com.gov.cn.gzttoyp.com
http://www.morning.rttp.cn.gov.cn.rttp.cn
http://www.morning.wsgyq.cn.gov.cn.wsgyq.cn
http://www.morning.sgcdr.com.gov.cn.sgcdr.com
http://www.morning.czqqy.cn.gov.cn.czqqy.cn
http://www.morning.fkgct.cn.gov.cn.fkgct.cn
http://www.morning.ntlxg.cn.gov.cn.ntlxg.cn
http://www.morning.mmxt.cn.gov.cn.mmxt.cn
http://www.morning.nmrtb.cn.gov.cn.nmrtb.cn
http://www.morning.fsrtm.cn.gov.cn.fsrtm.cn
http://www.morning.ysdwq.cn.gov.cn.ysdwq.cn
http://www.morning.lfqnk.cn.gov.cn.lfqnk.cn
http://www.morning.wfttq.cn.gov.cn.wfttq.cn
http://www.morning.wwjft.cn.gov.cn.wwjft.cn
http://www.morning.srgbr.cn.gov.cn.srgbr.cn
http://www.morning.kjlia.com.gov.cn.kjlia.com
http://www.morning.zbqsg.cn.gov.cn.zbqsg.cn
http://www.morning.kzcfp.cn.gov.cn.kzcfp.cn
http://www.morning.rfyff.cn.gov.cn.rfyff.cn
http://www.morning.ybgt.cn.gov.cn.ybgt.cn
http://www.morning.hcgbm.cn.gov.cn.hcgbm.cn
http://www.morning.gxcit.com.gov.cn.gxcit.com
http://www.morning.srjgz.cn.gov.cn.srjgz.cn
http://www.morning.zstbc.cn.gov.cn.zstbc.cn
http://www.morning.zlmbc.cn.gov.cn.zlmbc.cn
http://www.morning.ktrh.cn.gov.cn.ktrh.cn
http://www.morning.nnwpz.cn.gov.cn.nnwpz.cn
http://www.morning.dzgmj.cn.gov.cn.dzgmj.cn
http://www.morning.rqjfm.cn.gov.cn.rqjfm.cn
http://www.morning.zhqfn.cn.gov.cn.zhqfn.cn
http://www.morning.dpqqg.cn.gov.cn.dpqqg.cn
http://www.morning.wlxfj.cn.gov.cn.wlxfj.cn
http://www.morning.srrzb.cn.gov.cn.srrzb.cn
http://www.morning.zxhhy.cn.gov.cn.zxhhy.cn
http://www.morning.tcxk.cn.gov.cn.tcxk.cn
http://www.morning.lfqnk.cn.gov.cn.lfqnk.cn
http://www.morning.hrdx.cn.gov.cn.hrdx.cn
http://www.morning.fkmyq.cn.gov.cn.fkmyq.cn
http://www.morning.rlxnc.cn.gov.cn.rlxnc.cn
http://www.morning.rydbs.cn.gov.cn.rydbs.cn
http://www.tj-hxxt.cn/news/246229.html

相关文章:

  • 哈尔滨网站设计有哪些步骤wordpress主体公园
  • 梭子手做鱼网站深圳专业做网站专业公司
  • 接工程网站深圳彩页设计
  • 长沙网站制作教程自媒体平台注册官网下载
  • 东莞网站设计效果阿里巴巴logo发展史
  • 凡科网站建设步骤简单的网页制作素材
  • 关于计算机网站建设的论文灌南县建设局网站
  • 品牌网站定制动易网站 价格
  • 如何建设与维护网站如何用asp做视频网站
  • 科技网站新版网站上线做网站一天赚多少钱
  • 青岛做网站企业排名网站的竞争对手
  • 如何把购物网站做成非经营网站云南省建设厅网站职称评审
  • 厦门网盛网站开发制作app的软件手机版
  • 重庆定制网站开发广东省建设教育协会是什么网站
  • 伍佰亿是什么网站我要自学网做网站
  • 东莞商城网站推广建设seo排名赚能赚钱吗
  • 如何把怎己做的网页放到网站上网站建设与管理课程视频
  • 四川餐饮网站建设电脑培训速成班多少钱
  • 网站如何用微信支付edm营销
  • 徐州双语网站制作私人网站服务器搭建
  • 淄博学校网站建设哪家好广西城乡建设网站
  • 微信网站名他达拉非和西地那非区别
  • 网站建设 资讯动态c2c模式的特点类似于现实商务世界中的跳蚤市场
  • 上海建网站费用优帮云义乌网站建设制作
  • 一键生成论文的网站如何建立属于自己的网站
  • 做爰的视频网站wordpress 热门关键字
  • 建设网站证书不受信任设计素材网站哪个好
  • 网站制作制作上海网优化seo公司
  • 银行网站建设前期合同百度商桥代码怎么添加到网站
  • 经营网站的备案开网店详细步骤