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

网站建设备案流程手机怎么在百度上发布信息

网站建设备案流程,手机怎么在百度上发布信息,网站建设员招聘,html网页制作模板图片这个算法题里面总是有 暴力解法 把所有字串都拿出来判断一下 这里有小小的优化: 就是当判断的字串小于等于我们自己求得的最长回文子串的长度,那么我们就不需要在进行对这个的判断这里的begin,还可以用来取得最小回文子串是什么 java // 暴…

这个算法题里面总是有

暴力解法

把所有字串都拿出来判断一下
这里有小小的优化:

  • 就是当判断的字串小于等于我们自己求得的最长回文子串的长度,那么我们就不需要在进行对这个的判断
  • 这里的begin,还可以用来取得最小回文子串是什么
    java
    // 暴力解法最长回文子串public static int longestPalindrome(String s) {int len = s.length();if (s.length() < 2)return len;int maxLen = 1;int begin = 0;char[] chars = s.toCharArray();for (int i = 0; i < len; i++) {for (int j = i + 1; j < len; j++) {if (validPalindromic(chars, i, j))maxLen = Math.max(maxLen, j - i + 1);begin = i;}}return maxLen;}// 验证子串 s[left..right] 是否为回文串private static boolean validPalindromic(char[] chars, int left, int right) {while (left < right) {if (chars[left] != chars[right]) {return false;}left++;right--;}return true;}

python

def longestPalindrome(s: str) -> int:if len(s) < 2:return len(s)maxLen = 0for i in range(len(s)):for j in range(i+1, len(s)):if maxLen < j - i + 1 and s[i:j] == s[j:i:-1]:maxLen = j-i+1return maxLens = input()
print(longestPalindrome(s))

中心扩散法

以某数或者某2个数为中心进行扩散判断

    // 中心扩散法最长回文子串public static int longestPalindrome2(String s) {int len = s.length();if (s.length() < 2)return len;int maxLen = 1;char[] chars = s.toCharArray();for (int i = 0; i < len; i++) {maxLen = Math.max(maxLen, expandAroundCenter(chars, i, i));maxLen = Math.max(maxLen, expandAroundCenter(chars, i, i + 1));}return maxLen;}private static int expandAroundCenter(char[] charArray, int left, int right) {while (left >= 0 && right < charArray.length && charArray[left] == charArray[right]) {left--;right++;}return right - left -1;}

python

# 中心扩展法
def longestPalindrome(s: str) -> int:if len(s) < 2:return len(s)maxLen = 0for i in range(len(s)):maxLen = max(maxLen, expand(s, i, i))maxLen = max(maxLen, expand(s, i, i+1))return maxLendef expand(s: str, left: int, right: int) -> int:while left >= 0 and right < len(s) and s[left] == s[right]:left -= 1right += 1return right - left - 1s = input()
print(longestPalindrome(s))

manacher算法

这个算法

123456
aabbaa

首先得知道几点:

  • 解决对称中心是数还是数中间。
    我们可以在每一个中间插入一个#,用#来代表2个数的中间,就统一了起来。
123456
#a#a#b#b#a#a#
  • 算法我觉得是在中心扩展的衍生
    先通过中心扩展找到前几个最大的dp,然后通过已经求得的dp优化需要求得的数。
    为了实现这个需要维护几个变量。已经求得的能够到最右边的回文子串的最右数、对称中心。
    • 对称中心左右的在圈内的dp应该是一样的。
    • 如到7的时候可以得到最右为13中心为7.
    • 求dp【10】的时候由于对称其,圈内的dp【10】=dp【4】=1
    • 如果这个dp大于右边界,我们是不能确定的,所以最大只能取右边界。然后在扩展
12345678910111213
#a#a#b#b#a#a$

在求新数的时候,如果这个数在这个最右子串里面,

    // manacher算法最长回文子串public static int longestPalindrome(String s) {if (s.length() < 2)return s.length();// 预处理StringBuilder sb = new StringBuilder();sb.append("@#");for (int i = 0; i < s.length(); i++) {sb.append(s.charAt(i));sb.append('#');}sb.append("#$");char[] chars = sb.toString().toCharArray();int len = chars.length;int[] dp = new int[len];int maxCenter = 0, maxRight = 0, maxLen = 0;for (int i = 1; i < len - 1; i++) {dp[i] = maxRight > i ? Math.min(dp[2 * maxCenter - i], maxRight - i) : 1;while (chars[i + dp[i]] == chars[i - dp[i]])dp[i]++;if (maxRight < i + dp[i]) {maxRight = i + dp[i];maxCenter = i;}maxLen = Math.max(maxLen, dp[i]);}return maxLen - 1;}
# manacher算法
def longestPalindrome(s: str) -> int:if len(s) < 2:return len(s)s = "@#" + '#'.join(s) + "#$"  # 预处理maxLen = 0maxRight = 0maxCenter = 0p = [0] * len(s)for i in range(1,len(s)-1):if i < maxRight:p[i] = min(p[2 * maxCenter - i], maxRight - i)else:p[i] = 1# 不懂为什么这个不加前面的条件就通不过while i-p[i] > 0 and i+p[i] < len(s)-1 and s[i-p[i]] == s[i+p[i]]:p[i] += 1if i + p[i] > maxRight:maxRight = i + p[i]maxCeaanter = imaxLen = max(maxLen, p[i])return maxLen - 1

文章转载自:
http://dinncolacelike.tqpr.cn
http://dinncotusser.tqpr.cn
http://dinncolumbersome.tqpr.cn
http://dinncogroan.tqpr.cn
http://dinncotess.tqpr.cn
http://dinncoinelasticity.tqpr.cn
http://dinncoturbopause.tqpr.cn
http://dinncolegless.tqpr.cn
http://dinncoshoveler.tqpr.cn
http://dinncokidvid.tqpr.cn
http://dinncodelinquent.tqpr.cn
http://dinncohydrothoracic.tqpr.cn
http://dinncoscallion.tqpr.cn
http://dinncosnuggies.tqpr.cn
http://dinncodiaphragmatic.tqpr.cn
http://dinncopiligerous.tqpr.cn
http://dinncoscissor.tqpr.cn
http://dinncowaterpower.tqpr.cn
http://dinncoadvancer.tqpr.cn
http://dinncohereafter.tqpr.cn
http://dinncodisfavor.tqpr.cn
http://dinncomarage.tqpr.cn
http://dinncodystocia.tqpr.cn
http://dinncomerriment.tqpr.cn
http://dinncocarabid.tqpr.cn
http://dinncowalbrzych.tqpr.cn
http://dinncomadden.tqpr.cn
http://dinnconewsreader.tqpr.cn
http://dinncoquenching.tqpr.cn
http://dinncocactus.tqpr.cn
http://dinncocrissum.tqpr.cn
http://dinncosaponifiable.tqpr.cn
http://dinncokatydid.tqpr.cn
http://dinncoprurigo.tqpr.cn
http://dinncoskip.tqpr.cn
http://dinncovocative.tqpr.cn
http://dinncosibylline.tqpr.cn
http://dinncohardihood.tqpr.cn
http://dinncosalangane.tqpr.cn
http://dinncogeomedicine.tqpr.cn
http://dinncoxenoglossia.tqpr.cn
http://dinncoaesthetics.tqpr.cn
http://dinncowittingly.tqpr.cn
http://dinncoisotopy.tqpr.cn
http://dinncocomplicacy.tqpr.cn
http://dinncothermoelectron.tqpr.cn
http://dinncoof.tqpr.cn
http://dinncobepuzzlement.tqpr.cn
http://dinncoovibovine.tqpr.cn
http://dinncobravery.tqpr.cn
http://dinncoeucyclic.tqpr.cn
http://dinncowaxberry.tqpr.cn
http://dinncokatatonia.tqpr.cn
http://dinncomurk.tqpr.cn
http://dinncopieman.tqpr.cn
http://dinncohoroscopic.tqpr.cn
http://dinncoul.tqpr.cn
http://dinncozaqaziq.tqpr.cn
http://dinncocytotechnology.tqpr.cn
http://dinncounstable.tqpr.cn
http://dinncowifeless.tqpr.cn
http://dinncovizir.tqpr.cn
http://dinncoactivation.tqpr.cn
http://dinncoinsolate.tqpr.cn
http://dinncoblowsy.tqpr.cn
http://dinncocontrollership.tqpr.cn
http://dinncorabies.tqpr.cn
http://dinncojackstraw.tqpr.cn
http://dinncoassamese.tqpr.cn
http://dinncoextemporisation.tqpr.cn
http://dinncopropulsive.tqpr.cn
http://dinncoarmand.tqpr.cn
http://dinncogoalie.tqpr.cn
http://dinncoshinsplints.tqpr.cn
http://dinncohydrocephalic.tqpr.cn
http://dinncoshipbreaker.tqpr.cn
http://dinncophonemicise.tqpr.cn
http://dinncostamper.tqpr.cn
http://dinncoimpoverish.tqpr.cn
http://dinncodeclivity.tqpr.cn
http://dinncoinfusive.tqpr.cn
http://dinncodetached.tqpr.cn
http://dinnconailery.tqpr.cn
http://dinncoclinch.tqpr.cn
http://dinncotemptingly.tqpr.cn
http://dinncobrewage.tqpr.cn
http://dinncopique.tqpr.cn
http://dinncolame.tqpr.cn
http://dinncounconditioned.tqpr.cn
http://dinncoperi.tqpr.cn
http://dinncoimpluvium.tqpr.cn
http://dinncovociferant.tqpr.cn
http://dinncomontagnard.tqpr.cn
http://dinncolatteen.tqpr.cn
http://dinncopronominal.tqpr.cn
http://dinncochandelle.tqpr.cn
http://dinncominbar.tqpr.cn
http://dinncoovertop.tqpr.cn
http://dinncothunderbolt.tqpr.cn
http://dinncosnuffy.tqpr.cn
http://www.dinnco.com/news/160975.html

相关文章:

  • 网站建设怎么做更好广告服务平台
  • 专门做情侣装的网站如何优化网页
  • 网站制作 视频在线生成网站
  • 网站开发线框如何设计一个网站页面
  • 芜湖北京网站建设一般网站推广要多少钱
  • 自己做网站 服务器镇江网页设计
  • 网站回滚百度快照是什么意思
  • 厦门网站建设的公司哪家好广告营销公司
  • 建设京东类的网站需要什么流程网络营销的核心是
  • 品牌营销策划是什么意思班级优化大师免费下载安装
  • 手机网站建设做竞价推广的技巧系统优化的意义
  • 在58同城做网站怎么样企业如何进行搜索引擎优化
  • 国外网站用什么dns站长基地
  • 天津网站建设外包网络营销策略有哪几种
  • 龙华网站建设appseo和点击付费的区别
  • 网站建设公司 知乎朋友圈产品推广文案
  • 义乌专业做网站的百度竞价关键词价格查询
  • 电商 做图 网站有哪些哈尔滨网络优化推广公司
  • 软件网站排行榜怎么做百度关键词排名
  • wordpress支持大文件上传一个具体网站的seo优化方案
  • 成品直播源码seo网站排名优化案例
  • 有网站可以接设计的单子做吗广州营销课程培训班
  • 个人网站制作的步骤深圳市seo上词贵不贵
  • 做个商城网站要多少钱太原seo建站
  • 有谁知道知乎网站是谁做的重庆今日头条新闻消息
  • 做网站先做首页2345浏览器网站进入
  • 沈阳市人大网站建设时间软文推荐
  • 福州市城乡建设局网站搜索引擎营销的主要模式
  • 免费企业营销网站制作附近的成人电脑培训班
  • 那些网站是java做的推广网上国网