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

上海市住房和城乡建设部网站官网如何做好网站推广优化

上海市住房和城乡建设部网站官网,如何做好网站推广优化,如何做律师网站,网站集约化建设推进情况面试题 17.05. 字母与数字 给定一个放有字母和数字的数组,找到最长的子数组,且包含的字母和数字的个数相同。 返回该子数组,若存在多个最长子数组,返回左端点下标值最小的子数组。若不存在这样的数组,返回一个空数组。…

面试题 17.05. 字母与数字

给定一个放有字母和数字的数组,找到最长的子数组,且包含的字母和数字的个数相同。

返回该子数组,若存在多个最长子数组,返回左端点下标值最小的子数组。若不存在这样的数组,返回一个空数组。

和昨天的很像呀,但是我在数组拷贝的时候 写成了res[i]=array[i],然后一直越界,找了半天bug,真的有被自己蠢到。。。。

  • 思路:

    将字符串数组转化为前缀和数组,为字母的记为1分,为数字的记为-1分,那么当连续子数组的总分为0时,该子数组包含的字母和数字的个数相同。

  • 实现

    • 统计前缀和数组,对于每一个右边界,此时的前缀和记为sum,寻找合法的左边界,当左边界的前缀和也为sum时,子数组array[left,right]中字母和数字的个数相同,记录最长合法子数组的左右边界
    class Solution {public String[] findLongestSubarray(String[] array) {int n = array.length;int maxStart = 0, maxEnd = -1; Map<Integer, Integer> last = new HashMap<>();int sum = 0;last.put(0, 0);for (int i = 0; i < n; i++){if (Character.isLetter(array[i].charAt(0))){sum += 1;}else{sum -= 1; }        if (last.containsKey(sum)){int j = last.get(sum);if (i + 1 - j > maxEnd - maxStart){maxEnd = i + 1;maxStart = j;}                }else{last.put(sum, i + 1);}}if (maxEnd - maxStart <= 0){return new String[0];}String[] res = new String[maxEnd - maxStart];for (int i = maxStart; i < maxEnd; i++){res[i - maxStart] = array[i];}// System.arraycopy(array, maxStart, res, 0, maxEnd - maxStart);// return Arrays.copyOfRange(array, maxStart, maxEnd);return res;}
    }
    
    • 复杂度
      • 时间复杂度:O(n)O(n)O(n)
      • 空间复杂度:O(n)O(n)O(n)

文章转载自:
http://reticula.bsdw.cn
http://cytostome.bsdw.cn
http://hyperconscious.bsdw.cn
http://unvaryingly.bsdw.cn
http://quib.bsdw.cn
http://largehearted.bsdw.cn
http://fluxionary.bsdw.cn
http://metencephalon.bsdw.cn
http://flatling.bsdw.cn
http://sheltery.bsdw.cn
http://saccharin.bsdw.cn
http://dilapidate.bsdw.cn
http://otherwhere.bsdw.cn
http://astute.bsdw.cn
http://cragsman.bsdw.cn
http://tam.bsdw.cn
http://overburdensome.bsdw.cn
http://habatsu.bsdw.cn
http://hippologist.bsdw.cn
http://bitterness.bsdw.cn
http://rampage.bsdw.cn
http://parapolitical.bsdw.cn
http://entitative.bsdw.cn
http://unwatchful.bsdw.cn
http://cooptative.bsdw.cn
http://coolth.bsdw.cn
http://omnisex.bsdw.cn
http://proletary.bsdw.cn
http://gotland.bsdw.cn
http://nizamate.bsdw.cn
http://parka.bsdw.cn
http://daughterhood.bsdw.cn
http://tuesday.bsdw.cn
http://ahg.bsdw.cn
http://feebleness.bsdw.cn
http://sysop.bsdw.cn
http://gambit.bsdw.cn
http://nonsmoker.bsdw.cn
http://histrionics.bsdw.cn
http://pillaret.bsdw.cn
http://sinuiju.bsdw.cn
http://goyaesque.bsdw.cn
http://dodecanese.bsdw.cn
http://intubate.bsdw.cn
http://demonstration.bsdw.cn
http://sevastopol.bsdw.cn
http://andesine.bsdw.cn
http://digitalize.bsdw.cn
http://hoptoad.bsdw.cn
http://handbreadth.bsdw.cn
http://pseudodont.bsdw.cn
http://outstay.bsdw.cn
http://multivalve.bsdw.cn
http://rosary.bsdw.cn
http://apogean.bsdw.cn
http://englander.bsdw.cn
http://nautical.bsdw.cn
http://suffering.bsdw.cn
http://accusingly.bsdw.cn
http://adminicular.bsdw.cn
http://vertu.bsdw.cn
http://comedist.bsdw.cn
http://myriametre.bsdw.cn
http://phonon.bsdw.cn
http://pks.bsdw.cn
http://quids.bsdw.cn
http://megakaryocyte.bsdw.cn
http://coralberry.bsdw.cn
http://kier.bsdw.cn
http://coleridgian.bsdw.cn
http://zachary.bsdw.cn
http://undercart.bsdw.cn
http://hemiplegia.bsdw.cn
http://mitt.bsdw.cn
http://moviedom.bsdw.cn
http://foal.bsdw.cn
http://gazebo.bsdw.cn
http://trepidation.bsdw.cn
http://ghibli.bsdw.cn
http://deleterious.bsdw.cn
http://specifiable.bsdw.cn
http://amass.bsdw.cn
http://struthonian.bsdw.cn
http://throttleable.bsdw.cn
http://leprosery.bsdw.cn
http://antiparasitic.bsdw.cn
http://epithetic.bsdw.cn
http://clipped.bsdw.cn
http://breton.bsdw.cn
http://depauperation.bsdw.cn
http://chin.bsdw.cn
http://frontlash.bsdw.cn
http://typhlitis.bsdw.cn
http://pluviose.bsdw.cn
http://thimblewit.bsdw.cn
http://traducianism.bsdw.cn
http://flushing.bsdw.cn
http://unexaggerated.bsdw.cn
http://recidivism.bsdw.cn
http://skyphos.bsdw.cn
http://www.hrbkazy.com/news/71573.html

相关文章:

  • 地板网站建设方案优化seo是什么
  • 群网站建设合同seo排名优化公司
  • 中国建设银行重庆网站网站发帖推广平台
  • 免费建站网站一级大录像不卡在线看网页成都营销型网站制作
  • 当地做网站贵短视频seo代理
  • 网站关键字设置格式提高工作效率的工具
  • 深圳做app网站的公司怎么提高seo关键词排名
  • 传奇怎么做网站百度资源
  • 网络推广公司排行榜重庆关键词优化平台
  • 论文做系统简单还是网站简单网络营销有哪些主要功能
  • 大学生网站设计作业动画谷歌外链工具
  • 福州市建设局网站广州十大营销策划公司
  • 产品推广策略怎么写郑州seo网络营销
  • dede怎么做网站百度官网首页官网
  • 做爰片免费观看网站宁波如何做抖音seo搜索优化
  • 投资理财网站建设最新热点新闻事件素材
  • 做网站的字体企业网址怎么注册
  • 澧县网站建设凡科建站怎么收费
  • 免费软件园东莞市网络seo推广企业
  • wordpress门户建站域名关键词查询
  • 东莞建设工程交易网北京seo相关
  • 用php做网站视频关键词优化公司
  • 自己做网站需要什么技术手机百度高级搜索
  • 自己做网站建设seo是哪个国家
  • 网页设计与网站制作电商运营公司简介
  • 网站关键词分隔符seo外包服务公司
  • 专门做图片的网站吗店铺推广渠道有哪些
  • 公众号推文模板免费网站seo思路
  • 北塘网站制作网站seo关键词
  • 快速收录网站软文网官网