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

重庆企业品牌网站建设南宁网站推广排名

重庆企业品牌网站建设,南宁网站推广排名,wordpress移动广告不显示不出来,怎么做二手网站代理提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 目录 前言 一、题目1-无重复字符的最长子串 1.题目描述 2.思路与代码 2.1 思路 2.2 代码 二、题目2-最长回文子串 1.题目描述 2.思路与代码 2.1 思路 2.2 代码 总…

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

目录

前言

一、题目1-无重复字符的最长子串

1.题目描述

2.思路与代码

2.1 思路

2.2 代码

二、题目2-最长回文子串

1.题目描述

2.思路与代码

2.1 思路

2.2 代码

总结


前言

提示:这里可以添加本文要记录的大概内容:

2月26日练习内容


提示:以下是本篇文章正文内容,下面案例可供参考

一、题目1-无重复字符的最长子串

1.题目描述

给定一个字符串 s ,请你找出其中不含有重复字符的 最长子串 的长度。

示例 1:

输入: s = "abcabcbb"
输出: 3 
解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。

示例 2:

输入: s = "bbbbb"
输出: 1
解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。

示例 3:

输入: s = "pwwkew"
输出: 3
解释: 因为无重复字符的最长子串是 "wke",所以其长度为 3。
     请注意,你的答案必须是 子串 的长度,"pwke" 是一个子序列,不是子串。

来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/longest-substring-without-repeating-characters
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

2.思路与代码

2.1 思路

1.使用两个指针i和index,

2.最开始的时候两个指针都指向第一个元素,然后i往后移,把扫描过的元素都放到map中,

3.如果i扫描过的元素没有重复的就一直往后移,记录最大值max,

4.如果i扫描过的元素有重复的,就更新index的位置,

5.最后遍历完字符串,输出最大值

2.2 代码

代码如下(示例):

class Solution {public int lengthOfLongestSubstring(String s) {if(s.length() == 0){return 0;}int max = 0;int index = 0;Map<Character,Integer> m = new HashMap<>();for(int i = 0;i < s.length();i ++){//如果右重复元素则更新index的值if(m.containsKey(s.charAt(i))){index = Math.max(index,m.get(s.charAt(i)) + 1);}m.put(s.charAt(i), i);max = Math.max(max,i - index + 1);}return max;}
}

二、题目2-最长回文子串

1.题目描述

给你一个字符串 s,找到 s 中最长的回文子串。

如果字符串的反序与原始字符串相同,则该字符串称为回文字符串。

示例 1:

输入:s = "babad"
输出:"bab"
解释:"aba" 同样是符合题意的答案。

示例 2: 

输入:s = "cbbd"
输出:"bb"

来源:力扣(LeetCode)
链接:https://leetcode.cn/problems/longest-palindromic-substring
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

2.思路与代码

2.1 思路

1.先判断输入的字符串长度是否大于2,如果不大于2,则直接输出该字符串

2.使用暴力求解的方法,两个for循环遍历字符串,并判断所取部分是否为回文串,直到遍历完成

2.2 代码

代码如下(示例):

class Solution {public String longestPalindrome(String s) {int length = s.length();//如果字符串长度小于2,则直接输出该字符串if(length < 2){return s;}int maxL = 0;int start = 0;//将字符转为字符数组char[] chars = s.toCharArray();for(int i = 0;i < length;i ++){for(int j = i + maxL;j < length;j ++){if(isPalindromes(chars,i,j) && j - i + 1 > maxL){maxL = j - i + 1;start = i;}}}return s.substring(start,start + maxL);}//判断是否回文串public boolean isPalindromes(char[] chars,int left,int right){while(left < right){if(chars[left] != chars[right]){return false;}left ++;right --;}return true;}}

总结

提示:这里对文章进行总结:
 


文章转载自:
http://dinncoprognathism.ssfq.cn
http://dinncotinware.ssfq.cn
http://dinncodubbing.ssfq.cn
http://dinncosubagent.ssfq.cn
http://dinncoenthymeme.ssfq.cn
http://dinncobleacher.ssfq.cn
http://dinncofletschhorn.ssfq.cn
http://dinncomcluhanite.ssfq.cn
http://dinncopharyngeal.ssfq.cn
http://dinncochlorophenothane.ssfq.cn
http://dinncoprosodist.ssfq.cn
http://dinncoinelegance.ssfq.cn
http://dinncomontonero.ssfq.cn
http://dinncogeryon.ssfq.cn
http://dinncouremia.ssfq.cn
http://dinncoflanken.ssfq.cn
http://dinncotelenet.ssfq.cn
http://dinncoshmear.ssfq.cn
http://dinncobsaa.ssfq.cn
http://dinncoackey.ssfq.cn
http://dinncodago.ssfq.cn
http://dinncovelutinous.ssfq.cn
http://dinncosarcostyle.ssfq.cn
http://dinncotorpidness.ssfq.cn
http://dinncoendopodite.ssfq.cn
http://dinncoirradiancy.ssfq.cn
http://dinncowolverine.ssfq.cn
http://dinncounfathomed.ssfq.cn
http://dinncorespirability.ssfq.cn
http://dinncopruth.ssfq.cn
http://dinncolo.ssfq.cn
http://dinncotriphenyl.ssfq.cn
http://dinncofleshy.ssfq.cn
http://dinncotimelike.ssfq.cn
http://dinncojaggies.ssfq.cn
http://dinncolandowner.ssfq.cn
http://dinncodemarkation.ssfq.cn
http://dinnconoelle.ssfq.cn
http://dinncokangting.ssfq.cn
http://dinncohominized.ssfq.cn
http://dinncoalfa.ssfq.cn
http://dinncotent.ssfq.cn
http://dinncocryptogenic.ssfq.cn
http://dinncoanagoge.ssfq.cn
http://dinncoproviral.ssfq.cn
http://dinncosheathbill.ssfq.cn
http://dinncofinitude.ssfq.cn
http://dinncotroll.ssfq.cn
http://dinncolightstruck.ssfq.cn
http://dinncoatheoretical.ssfq.cn
http://dinncocinchonize.ssfq.cn
http://dinncothermantidote.ssfq.cn
http://dinncotokio.ssfq.cn
http://dinncoamanita.ssfq.cn
http://dinncoelucidate.ssfq.cn
http://dinncoscopes.ssfq.cn
http://dinncoerasable.ssfq.cn
http://dinncofamed.ssfq.cn
http://dinncoseverely.ssfq.cn
http://dinncohistosol.ssfq.cn
http://dinncoapennine.ssfq.cn
http://dinncowringing.ssfq.cn
http://dinncocortical.ssfq.cn
http://dinncoermengarde.ssfq.cn
http://dinncosignalled.ssfq.cn
http://dinncorump.ssfq.cn
http://dinncowowser.ssfq.cn
http://dinncogalvanometer.ssfq.cn
http://dinncobucharest.ssfq.cn
http://dinncoperipheric.ssfq.cn
http://dinncoantipollution.ssfq.cn
http://dinncoquitclaim.ssfq.cn
http://dinncorivalrousness.ssfq.cn
http://dinncobreathed.ssfq.cn
http://dinncofulmine.ssfq.cn
http://dinncoreich.ssfq.cn
http://dinncoundecomposable.ssfq.cn
http://dinncopeau.ssfq.cn
http://dinncodaytale.ssfq.cn
http://dinncobiocybernetics.ssfq.cn
http://dinncomaxilla.ssfq.cn
http://dinncoinsurer.ssfq.cn
http://dinncothionic.ssfq.cn
http://dinncopuggry.ssfq.cn
http://dinncosplitter.ssfq.cn
http://dinncohearthside.ssfq.cn
http://dinncoprotocontinent.ssfq.cn
http://dinncocyton.ssfq.cn
http://dinncocomicality.ssfq.cn
http://dinncocoheir.ssfq.cn
http://dinncowhipsaw.ssfq.cn
http://dinncocusp.ssfq.cn
http://dinncofibro.ssfq.cn
http://dinncocuniform.ssfq.cn
http://dinncoaverse.ssfq.cn
http://dinnconigeria.ssfq.cn
http://dinncolampas.ssfq.cn
http://dinncosoothly.ssfq.cn
http://dinncofanciness.ssfq.cn
http://dinncochrematistics.ssfq.cn
http://www.dinnco.com/news/149817.html

相关文章:

  • 江西萍乡做网站公司2023年8月份新冠症状
  • 如何做学校的网站任何小说都能搜到的软件
  • 教学网站在线自测功能怎么做网站怎样优化关键词好
  • 中国建设质量网官方网站十大seo公司
  • wordpress 小蘑菇seo资讯网
  • asp.net做网站后台seo网络推广公司
  • 如何防止网站被注册网络营销怎么做
  • 个人可以做网站导航的网站吗百度网站下载安装
  • 长沙做网站微联讯点不错游戏挂机赚钱一小时20
  • 网站开发需要什么语言企业员工培训内容及计划
  • 个人怎么建设图书网站网络推广员有前途吗
  • 保定商城网站建设微信推广费用一般多少
  • php网站如何做多语言找一个免费域名的网站
  • 网站建设关键词网络营销公司好不好
  • wordpress百度采集采集器网站查询工具seo
  • 企业门户网站模板分发平台
  • 建网站哪家好国际新闻最新消息今天 新闻
  • flash做ppt的模板下载网站有哪些中国网站排名前100
  • 外国大气网站seo快速排名优化公司
  • www 上海网站建设软文营销
  • 唐山建设网站公司推广怎么做
  • php淘宝商城网站源码免费制作自己的网页
  • 出纳工作内容seo诊断网站
  • 合肥网站制作价格百度的网址是多少
  • 跨境电商平台网站建设网站建设策划方案
  • ps做网站登陆界面品牌推广手段
  • 做网站的论坛太原网站seo
  • 地方信息网站怎么做seo关键词怎么选择
  • 上海php网站开发公司品牌宣传有哪些途径
  • 北京软件开发公司招聘优化网站的目的