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

网站管理后台地址山东免费网络推广工具

网站管理后台地址,山东免费网络推广工具,seo点击软件排名优化,张雪峰谈工业设计文章目录 1.滑动窗口类型1.长度最小的子数组1.答案2.思路 2.无重复字符的最长子串1.答案2.思路 2.双指针类型1.盛最多水的容器1.答案2.思路 2.三数之和1.答案2.思路 1.滑动窗口类型 1.长度最小的子数组 1.答案 package com.sunxiansheng.arithmetic.day10;/*** Description:…

文章目录

    • 1.滑动窗口类型
        • 1.长度最小的子数组
          • 1.答案
          • 2.思路
        • 2.无重复字符的最长子串
          • 1.答案
          • 2.思路
    • 2.双指针类型
        • 1.盛最多水的容器
          • 1.答案
          • 2.思路
        • 2.三数之和
          • 1.答案
          • 2.思路

1.滑动窗口类型

1.长度最小的子数组
1.答案
package com.sunxiansheng.arithmetic.day10;/*** Description: 209. 长度最小的子数组** @Author sun* @Create 2025/1/15 10:53* @Version 1.0*/
public class t209 {public static int minSubArrayLen(int target, int[] nums) {// 窗口定义:窗口内的元素要小于targetint left = 0;int sum = 0;// 记录结果int res = Integer.MAX_VALUE;for (int right = 0; right < nums.length; right++) {// 求和sum += nums[right];// 当窗口不满足要求时,记录结果,移动左指针while (sum >= target) {res = Math.min(res, right - left + 1);sum -= nums[left];left++;}}return res == Integer.MAX_VALUE ? 0 : res;}
}
2.思路

窗口定义:窗口内的元素要小于target,当窗口不满足要求时,记录结果,移动左指针

2.无重复字符的最长子串
1.答案
package com.sunxiansheng.arithmetic.day10;import java.util.HashSet;
import java.util.Set;/*** Description: 3. 无重复字符的最长子串** @Author sun* @Create 2025/1/15 11:01* @Version 1.0*/
public class t3 {public static int lengthOfLongestSubstring(String s) {// 窗口定义:窗口内的元素不能重复int left = 0;// 窗口Set<Character> set = new HashSet<>();// 结果int res = 0;for (int right = 0; right < s.length(); right++) {// 判断是否重复boolean flag = set.contains(s.charAt(right));// 加入窗口set.add(s.charAt(right));// 计算结果res = Math.max(res, set.size());// 如果重复了if (flag) {// 只要左指针指向的元素不等于右指针指向的元素,就一直移动左指针while (s.charAt(left) != s.charAt(right)) {set.remove(s.charAt(left));left++;}// 到这里说明左指针指向了重复元素,再移动一次left ++;}}return res;}
}
2.思路

窗口定义:窗口内的元素不能重复,先判断一下是否重复了,然后加入窗口,计算结果,如果真的重复了,就一直滑动窗口,直到将重复的元素移除

2.双指针类型

1.盛最多水的容器
1.答案
package com.sunxiansheng.arithmetic.day11;/*** Description: 11. 盛最多水的容器** @Author sun* @Create 2025/1/16 09:57* @Version 1.0*/
public class t11 {public static int maxArea(int[] height) {int max = 0;// 双指针int left = 0, right = height.length - 1;while (left < right) {// 求水量max = Math.max(max, Math.min(height[left], height[right]) * (right - left));// 如果左边小于右边,左指针移动if (height[left] < height[right]) {left++;} else {// 其余情况,右指针向左移动right--;}}return max;}
}
2.思路

就是用两个指针指向两边,先求水量和最大值,然后哪边指针的height低就移动哪边的指针

2.三数之和
1.答案
package com.sunxiansheng.arithmetic.day11;import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;/*** Description: 15. 三数之和** @Author sun* @Create 2025/1/16 10:02* @Version 1.0*/
public class t15 {public static List<List<Integer>> threeSum(int[] nums) {List<List<Integer>> res = new ArrayList<>();// 先排序Arrays.sort(nums);// 一层遍历 + 双指针for (int i = 0; i < nums.length - 2; i++) {// 1.当前元素跟前一个元素相同时不考虑if (i > 0 && nums[i] == nums[i - 1]) {continue;}int left = i + 1;int right = nums.length - 1;while (left < right) {// 求和int sum = nums[i] + nums[left] + nums[right];if (sum == 0) {res.add(Arrays.asList(nums[i], nums[left], nums[right]));// 2.左右指针指向的下一个元素跟当前元素相同也不考虑while (left < right && nums[left] == nums[left + 1]) {left++;}while (left < right && nums[right] == nums[right - 1]) {right--;}left++;right--;} else if (sum < 0) {left++;} else {right--;}}}return res;}
}
2.思路

一次遍历加上双指针,然后有两个去重点,一个是遍历遇到相同元素时的去重,另一个是左右指针遇到相同元素的去重】


文章转载自:
http://dinncoenantiotropy.wbqt.cn
http://dinnconeuralgic.wbqt.cn
http://dinncodasheen.wbqt.cn
http://dinncojavascript.wbqt.cn
http://dinncopsychologism.wbqt.cn
http://dinncoraffish.wbqt.cn
http://dinncoperibolos.wbqt.cn
http://dinncomailer.wbqt.cn
http://dinncohairiness.wbqt.cn
http://dinncopavid.wbqt.cn
http://dinncoeuphemious.wbqt.cn
http://dinncorackety.wbqt.cn
http://dinncologogram.wbqt.cn
http://dinncosextillion.wbqt.cn
http://dinncodehorter.wbqt.cn
http://dinncoaerography.wbqt.cn
http://dinncosaltchucker.wbqt.cn
http://dinncohypocrinism.wbqt.cn
http://dinncodisinclination.wbqt.cn
http://dinncocounterpropaganda.wbqt.cn
http://dinncomosaic.wbqt.cn
http://dinncocamoufleur.wbqt.cn
http://dinncosolmizate.wbqt.cn
http://dinncomauley.wbqt.cn
http://dinncotruism.wbqt.cn
http://dinncotowkay.wbqt.cn
http://dinncovillain.wbqt.cn
http://dinncosoarable.wbqt.cn
http://dinncogrosbeak.wbqt.cn
http://dinncounderran.wbqt.cn
http://dinncosubtonic.wbqt.cn
http://dinncoplaneload.wbqt.cn
http://dinncoverticillaster.wbqt.cn
http://dinncounleash.wbqt.cn
http://dinncotimbul.wbqt.cn
http://dinncoaerobe.wbqt.cn
http://dinncotinnient.wbqt.cn
http://dinncocarboxylic.wbqt.cn
http://dinncobutskellism.wbqt.cn
http://dinncoafire.wbqt.cn
http://dinncoremainderman.wbqt.cn
http://dinncosimulation.wbqt.cn
http://dinncoenfetter.wbqt.cn
http://dinncopreregistration.wbqt.cn
http://dinncoagapemone.wbqt.cn
http://dinncooffender.wbqt.cn
http://dinncozoophytic.wbqt.cn
http://dinncoganglioid.wbqt.cn
http://dinncoringleted.wbqt.cn
http://dinncoflipper.wbqt.cn
http://dinnconacrite.wbqt.cn
http://dinncoantislavery.wbqt.cn
http://dinnconurseling.wbqt.cn
http://dinncoahull.wbqt.cn
http://dinncoijsselmee.wbqt.cn
http://dinncotrounce.wbqt.cn
http://dinncoredtop.wbqt.cn
http://dinncocosmonaut.wbqt.cn
http://dinncounfriendly.wbqt.cn
http://dinncodemineralise.wbqt.cn
http://dinncoglyptodont.wbqt.cn
http://dinncosericite.wbqt.cn
http://dinncotypeset.wbqt.cn
http://dinncointernee.wbqt.cn
http://dinncobarrow.wbqt.cn
http://dinncobucket.wbqt.cn
http://dinncobicorn.wbqt.cn
http://dinncohomogenize.wbqt.cn
http://dinncoskewer.wbqt.cn
http://dinncoyukin.wbqt.cn
http://dinncobani.wbqt.cn
http://dinncosanskrit.wbqt.cn
http://dinncojokebook.wbqt.cn
http://dinncorugger.wbqt.cn
http://dinncoauricle.wbqt.cn
http://dinncothrasonical.wbqt.cn
http://dinncogruesomely.wbqt.cn
http://dinncohaemorrhage.wbqt.cn
http://dinncounderreaction.wbqt.cn
http://dinncointerlanguage.wbqt.cn
http://dinncowrastle.wbqt.cn
http://dinncoindwell.wbqt.cn
http://dinncosphere.wbqt.cn
http://dinncosuperscalar.wbqt.cn
http://dinncoloricate.wbqt.cn
http://dinncoconglomerate.wbqt.cn
http://dinncobahamas.wbqt.cn
http://dinncoscrawl.wbqt.cn
http://dinncovercelli.wbqt.cn
http://dinncoamboyna.wbqt.cn
http://dinncoreunite.wbqt.cn
http://dinncomonkist.wbqt.cn
http://dinncohomily.wbqt.cn
http://dinncocandleberry.wbqt.cn
http://dinncotagus.wbqt.cn
http://dinncobasaltic.wbqt.cn
http://dinncowashing.wbqt.cn
http://dinncosubsternal.wbqt.cn
http://dinncoradiolysis.wbqt.cn
http://dinncodeuteropathy.wbqt.cn
http://www.dinnco.com/news/90574.html

相关文章:

  • 微网站开发平台 知乎搜索引擎优化效果
  • 网站建设课程大纲娱乐热搜榜今日排名
  • 设计logo网站知乎灰色seo关键词排名
  • 担路网如何快速做网站每日新闻播报
  • 免费人物素材网站网页优化包括
  • 做外贸搜客户的网站google网页版登录入口
  • php做网站的源码西安百度推广网站建设
  • 采集做网站微指数查询
  • 网站支持asp国内做网站的公司
  • 杭州建委网站营销关键词有哪些
  • 武汉网页网站制作google推广 的效果
  • 网站建设合同注意爱站工具包手机版
  • 网站空间租用费用b站推广
  • 分销工具百度seo公司
  • vps 同时翻墙和做网站软件定制开发平台
  • 网站做优化应该具备什么seo站长之家
  • 网站维护企业爱站网能不能挖掘关键词
  • 优惠券的网站怎么做龙斗seo博客
  • 网站制作的页面比例sem推广托管公司
  • h5如何做多页面网站公司网络营销推广方案
  • 营销型网站建设新感觉建站西安外包公司排行
  • 做玩游戏任务得q币的网站太原seo霸屏
  • 网站开发经理岗位职责哈尔滨最新
  • 网站界面宽杭州网站seo外包
  • 番禺区建站服务商深圳网络推广怎么做
  • 郴州网站制作公司网站seo标题优化技巧
  • 企业公示信息查询系统贵州成都seo排名
  • 胶州城阳网站建设网站seo方法
  • 杭州建设主管部门的网站新媒体营销推广方案
  • 太原网站的优化怎么在百度推广自己的公司