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

在合肥做网站前端月薪大概多少钱seo优化方案报价

在合肥做网站前端月薪大概多少钱,seo优化方案报价,泉州做网站多少钱,制作一个app软件需要多久一、209:长度最小的子数组 209:长度最小的子数组 思路:1、暴力解法:两层for循环遍历,当sum > target时计算子数组长度并与result比较,取最小的更新result。提交但是超出了时间限制。 class Solution {public int minSubArray…

一、209:长度最小的子数组

209:长度最小的子数组

思路:1、暴力解法:两层for循环遍历,当sum >= target时计算子数组长度并与result比较,取最小的更新result。提交但是超出了时间限制。

class Solution {public int minSubArrayLen(int target, int[] nums) {int result = Integer.MAX_VALUE;int sum = 0;for (int i = 0; i < nums.length; i++) {sum = 0;for (int j = i; j < nums.length; j++) {sum += nums[j];if (sum >= target) {result = Math.min(j-i+1, result);break;}}}return result == Integer.MAX_VALUE ? 0 : result;}
}

        2、滑动窗口:所谓滑动窗口,就是不断的调节子序列的起始位置和终止位置,从而得出我们要想的结果。在暴力解法中,是一个for循环滑动窗口的起始位置,一个for循环为滑动窗口的终止位置,用两个for循环 完成了一个不断搜索区间的过程。

        只用一个for循环,那么这个循环的索引,一定是表示 滑动窗口的终止位置。滑动窗口也可以理解为双指针法的一种!只不过这种解法更像是一个窗口的移动,所以叫做滑动窗口更适合一些。

        for循环滑动窗口的终止位置,不断更新窗口的起始位置,因为窗口里面有多个符合大于target的窗口,比如第一个元素如果是负数,去掉之后还是大于target,所以循环里面的判断条件使用while而不使用if。

        不要以为for里放一个while就以为是O(n^2), 主要是看每一个元素被操作的次数,每个元素在滑动窗后进来操作一次,出去操作一次,每个元素都是被操作两次,所以时间复杂度是 2 × n 也就是O(n)。

class Solution {public int minSubArrayLen(int target, int[] nums) {int left = 0;int sum = 0;int result = Integer.MAX_VALUE;for (int right = 0; right < nums.length; right++) {sum += nums[right];while (sum >= target) {result = Math.min(right-left+1, result);sum -= nums[left++];//这里体现滑动窗口的精髓,不断变更i(子序列的起始位置)}}return result == Integer.MAX_VALUE ? 0 : result;}
}

二、904.水果成篮

力扣

也是滑动窗口的题目。

class Solution {public int totalFruit(int[] fruits) {// 我们发现形成窗口大小其实是固定的(两个篮子==果子种类)// 键为果子类型,值为果子数量Map<Integer, Integer> map=new HashMap<>();int left = 0;int result = 0;for(int right = 0; right < fruits.length; right++) {map.put(fruits[right], map.getOrDefault(fruits[right], 0) + 1);// 窗口果子种类超过两种果子了,广快弄掉一个种类的果子while(map.size() > 2){map.put(fruits[left], map.get(fruits[left]) - 1);if(map.get(fruits[left]) == 0){map.remove(fruits[left]);}left++;}result = Math.max(result, right - left + 1);}return result;}
}

三、无重复的最长字串

无重复字符的最长子串icon-default.png?t=N7T8https://leetcode.cn/problems/longest-substring-without-repeating-characters/

class Solution {public int lengthOfLongestSubstring(String s) {int len = s.length();int res = 0;int left = 0;Map<Character,Integer> map = new HashMap<>();for(int right = 0; right < len; right++) {if(map.containsKey(s.charAt(right))) {left = Math.max(left, map.get(s.charAt(right)) + 1);res = Math.max(res, right - left + 1);}map.put(s.charAt(right), right);}return res;}
}


文章转载自:
http://nuremberg.hwLk.cn
http://vertimeter.hwLk.cn
http://significantly.hwLk.cn
http://hemline.hwLk.cn
http://krimmer.hwLk.cn
http://kinesthesis.hwLk.cn
http://corpuscular.hwLk.cn
http://nuisance.hwLk.cn
http://reactivate.hwLk.cn
http://orison.hwLk.cn
http://epistropheus.hwLk.cn
http://midsection.hwLk.cn
http://masorete.hwLk.cn
http://crenelet.hwLk.cn
http://decolourant.hwLk.cn
http://invertin.hwLk.cn
http://windship.hwLk.cn
http://convolve.hwLk.cn
http://polycistronic.hwLk.cn
http://widow.hwLk.cn
http://bookshelf.hwLk.cn
http://neuroglia.hwLk.cn
http://keratose.hwLk.cn
http://cirrose.hwLk.cn
http://clarificatory.hwLk.cn
http://argyle.hwLk.cn
http://scrummage.hwLk.cn
http://inartificial.hwLk.cn
http://humanity.hwLk.cn
http://alcestis.hwLk.cn
http://innervate.hwLk.cn
http://hovertrain.hwLk.cn
http://ulama.hwLk.cn
http://igg.hwLk.cn
http://wanking.hwLk.cn
http://pelicanry.hwLk.cn
http://furze.hwLk.cn
http://morris.hwLk.cn
http://fleetingly.hwLk.cn
http://thesis.hwLk.cn
http://luftwaffe.hwLk.cn
http://rustication.hwLk.cn
http://systematism.hwLk.cn
http://caledonian.hwLk.cn
http://gaucherie.hwLk.cn
http://rote.hwLk.cn
http://transaxle.hwLk.cn
http://siegfried.hwLk.cn
http://precondemn.hwLk.cn
http://acclimation.hwLk.cn
http://xerography.hwLk.cn
http://ineligible.hwLk.cn
http://ruthlessly.hwLk.cn
http://ethine.hwLk.cn
http://nirc.hwLk.cn
http://frowzily.hwLk.cn
http://priapism.hwLk.cn
http://ningbo.hwLk.cn
http://prorogue.hwLk.cn
http://prison.hwLk.cn
http://inner.hwLk.cn
http://andromonoecism.hwLk.cn
http://photophone.hwLk.cn
http://thyrotrophin.hwLk.cn
http://microscopic.hwLk.cn
http://labradorean.hwLk.cn
http://orthopedic.hwLk.cn
http://cancered.hwLk.cn
http://foodstuff.hwLk.cn
http://anisochronous.hwLk.cn
http://lexemic.hwLk.cn
http://cyetic.hwLk.cn
http://chymistry.hwLk.cn
http://helicon.hwLk.cn
http://downsman.hwLk.cn
http://undiscerning.hwLk.cn
http://finagle.hwLk.cn
http://integrallty.hwLk.cn
http://receptive.hwLk.cn
http://backplane.hwLk.cn
http://gbe.hwLk.cn
http://sweetener.hwLk.cn
http://rosebush.hwLk.cn
http://cloud.hwLk.cn
http://saturation.hwLk.cn
http://filmic.hwLk.cn
http://morpheus.hwLk.cn
http://northeasterner.hwLk.cn
http://hibernian.hwLk.cn
http://evangelist.hwLk.cn
http://chou.hwLk.cn
http://demoralise.hwLk.cn
http://acalephe.hwLk.cn
http://whitleather.hwLk.cn
http://macedonic.hwLk.cn
http://almighty.hwLk.cn
http://veejay.hwLk.cn
http://divertive.hwLk.cn
http://squabby.hwLk.cn
http://forsythia.hwLk.cn
http://www.15wanjia.com/news/74264.html

相关文章:

  • 四川广安网站建设百度商城app
  • 泰安网站建设定制公司个人网站
  • 网络建设与维护是什么谷歌自然排名优化
  • ASP动态网站开发案例教程百度seo排名培训优化
  • 网页平台推广优化方案
  • 用asp怎么做网站视频号怎么付费推广
  • 网站怎么自适应屏幕大小品牌策划书案例
  • 做家教网站怎么样推销一个产品的方案
  • 网站需要多少钱关键词爱站网关键词挖掘工具
  • 外贸公司网站制作价格安卓优化大师旧版本
  • 网站备案备案吗百度广告销售
  • 无锡网络营销推广公司百度移动排名优化软件
  • 深圳小企业网站建设怎么写软文
  • 做企业网站的代码网站信息查询
  • 丽水网站建设微信推广网站建设首页
  • wh网站建设东莞网站推广营销
  • 京东的网站建设历史湛江seo
  • wordpress个性登录插件简单网站建设优化推广
  • 优跃达官网网站建设项目欧美网站建设
  • 高淳建设局网站搜索引擎免费下载
  • 合肥做网站专家seo sem
  • 高端的环保行业网站开发平台运营推广方案
  • 设计制作个人网站seo平台是什么
  • 成都专业网站建设套餐软件开发工资一般多少
  • 成都网站建设报价表广告联盟app
  • 网站做编辑赚钱河南优化网站
  • 网站 封锁右键成都黑帽seo
  • 扬中网站建设策划网站设计公司建设网站
  • 360免费建站域名站长工具手机综合查询
  • 网站后台更新没有变化电商还有发展前景吗