leetcode 5. Longest Palindromic Substring(最长回文子串)

王珊数据库系统概论第5版视频教材 目录 隐藏 说明:本课程共包括1种电子书、84个高清视频(共68课时)、1种纸质书(赠品)。 网授课程 王珊《数据库系统概论》(第5版)网授精讲班【共68课时】 序号 名称 课时 1 第1章 绪 论(1) 00:32:25 2 第1章 绪 论(2) 00:17:03 3 第1章 绪 论(3) 00:50:19 4 第1章 绪 论(4) 00:20:37 5 第1章 绪 论(5) 00:24:47 6 第2章 关系数据库(1) 00:47:23 7 第2章 关系数据库(2) 00:14:48 8 第2章 关系 阅读详情

Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.

Example 1:

Input: “babad”
Output: “bab”
Note: “aba” is also a valid answer.
Example 2:

Input: “cbbd”
Output: “bb”

给出一个字符串,输出其最长回文子串。
回文子串:左右对称的字符串

思路:
单个字符是回文子串。
以单个字符 s(i) 为中心,如果它的左右对称,即s(i-1) == s(i+1), 那么以 i 为中心,左右扩充一个字符的子串仍然是回文子串,这样扩充就可以得到以 i 为中心的最长回文子串。
那么取s的每个字符为中心都找一遍,就可得到最长回文子串。时间复杂度为O(n2)。
长度为偶数时需要取中心的两个字符,遍历s时两个一对为中心。

    public String longestPalindrome(String s) {
        if(s == null || s.length() == 0) {
            return "";
        }
        
        int start = 0;
        int len = 0;
        int n = s.length();
        for(int i = 0; i < n; i++) {
            int tmp = Math.max(getLen(s, i, i, n), getLen(s, i, i+1, n));
            if(tmp > len) {
                len = tmp;
               //start是左边的起始点,不是中心点, 先算len再算start
                start = i - (len - 1)/2;     
            }
        }
        
        return s.substring(start, start + len);
        
    }
    
    public int getLen(String s, int l, int r, int n) {
        while(l >= 0 && r < n && s.charAt(l) == s.charAt(r)) {
            l --;
            r ++;
        }
        //不满足条件结束循环时,l和r已经在子串外面,所以用以l,r为边界的字符串长度-2
        return (r - l -1);
    }
    

线型复杂度O(n)的Manacher’s Algorithm
具体思路后面补充,代码如下

    public String longestPalindrome(String s) {
        int id = 0;
	   int mx = 0;
	   int maxP = 0;
	   int maxId = 0;
	   int[] p = new int[s.length()*2 + 1];
       char[] str_insert = new char[s.length()*2 + 1];
       str_insert[0] = '#';
       for(int i = 0; i < str_insert.length-1; i ++){
    	   if(i % 2 == 0) {
    		   str_insert[i+1] = s.charAt(i/2);
    	   } else {
    		   str_insert[i+1] = '#';
    	   }
       }
       p[0] = 1;
       for(int i = 1; i < str_insert.length; i++){
    	   if(mx > i){
    		   p[i] = Math.min(p[2*id-i], mx-i);
    	   } else {
    		   p[i] = 1;
    	   }
    	   while(true){
    		   if(i+p[i] > str_insert.length-1 || i-p[i] < 0) {
    			   break;
    		   }
    		   if(str_insert[i + p[i]] == str_insert[i-p[i]]){
    			   p[i] ++;
    		   } else {
    			   break;
    		   }
    	   }
    	   if(p[i] > maxP) {
    		   maxP = p[i];
    		   maxId = i;
    	   }
    	   mx = i + p[i] - 1;
    	   id = i;
       }
       String string = new String(str_insert);
     //  System.out.println(Arrays.toString(p));
     //  System.out.println("maxId = " + maxId + ", maxP = " + maxP);
       StringBuilder result = new StringBuilder();
       for(int i = maxId - maxP + 1; i < maxId + maxP; i++){
    	   if(str_insert[i] != '#'){
    		   result.append(str_insert[i]);
    	   }
       }
	   return result.toString();
    }
《Java开发及前端最全面试题-Offer直通车》目录 Java开发是需求最广,工资高的细分领域,同时也是会的人最多,有的公司招1个Java开发,要面试几十甚至上百面试者,同时要求很高,要求通晓技术栈很多及很深深度。如果你正准备面试,想要脱颖而出,那么《Java开发及前端最全面试题-Offer直通车》是你的不二选择。本书汇集了多篇超过1万字的精华内容,无论是Java基础、数据库、SpringBoot和SpringCloud等必问的,还是前端、k8s等容器和虚拟化和大数据各类技术面试,本书都为你提供了最全面的试题和参考答案。 阅读详情

相关推荐

医学成像学习笔记(一):核磁共振成像(MRI)k空间为何是图像频谱详解

前言   k空间是核磁共振成像图像重建的核心,可能很多人像笔者一样第一次学时会非常疑惑,为何k空间是图像的频域空间,观其填充过程,明明是空域信号的采样填充呀。网上很少有文章讨论这个问题,所以笔者在此写下自己的理解,供大家参考。 MRI位置编码   现在的MRI一次扫描的是一个断层或者多个断层,所谓断层就是一个有厚度的面,通过z方向梯度场来选择。我们扫描一个断层的目的是为了获得该断层各位置的质子情况,它们携带着组织的性质信息,反应出来的就是信号强度。如果整个断层都采用相同的磁场强度,而我们只能得到一个断

意疏的学习笔记 1万+

5. 最长回文子串(高频题)

5. 最长回文子串题目解题思路代码 题目 给你一个字符串 s,找到 s 中最长的回文子串。 解题思路 把字符串的每一个字符当作中心,用左右指针向两侧扫描。记录每次的最长回文子序列,然后要注意奇数偶数的情况,详情见书374 代码 class Solution { public String longestPalindrome(String s) { if (s == null || s.length() == 0) { return ""; }

Hello World 404

从零到一:TI AWR1843 Boost EVM与DCA1000 EVM的ADC数据采集实战指南

本文详细介绍了TI AWR1843 Boost EVM与DCA1000 EVM的ADC数据采集实战指南,涵盖硬件连接、软件配置、固件烧录、雷达参数设置及数据处理等关键步骤。通过MATLAB等工具,开发者可高效实现毫米波雷达数据采集,适用于自动驾驶、工业检测等领域。

weixin_29001327的博客 966

LeetCode LongestPalindrome(最长回文子串)

LeetCode LongestPalindrome(最长回文子串) 题目:寻找字符串中最长回文子串 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例1 输入: “babad” 输出: “bab” 注意: “aba” 也是一个有效答案。 示例2 输入: “cbbd” 输出: “bb” 解题思路 思考 一看回文串的子串(去除头和尾的子串)也是回文串,就知...

bugcat的博客 528

企业微信微盘API权限避坑指南:为什么你的Python脚本无法获取文件列表?

本文深入解析了企业微信微盘API的权限模型,解释了为何即使使用超级管理员账号,Python脚本也可能因权限不足而无法获取文件列表。核心在于微盘API基于“应用身份”而非“用户身份”进行校验,应用只能访问自身创建的空间。文章提供了构建文件上传代理、利用事件回调等合规的替代方案,帮助企业实现高效数据同步。

weixin_29322553的博客 530

【Ragflow】9.问答为什么比搜索响应慢?从源码角度深入分析

前几天看到有群友提到一个现象:Ragflow的搜索界面的问答速度很快,但聊天界面的问答速度很慢,究竟是什么原因?在深入挖掘源码之后,逐渐发现了问题的答案。

兴趣使然的创作者 2900

查找字符串中的最长回文问题评述

class Solution { public: string longestPalindrome(string s) { string post; post.resize(s.size()*2+2); post[0] = '&'; for (int i = 0;i<s.size();i++){ post[2*i + 1] = s[i];

QXZ06的专栏 898

YOLO-World:从入门到实战的多模态目标检测全指南

想象一下,你给模型一张“公园”的图片,再输入文字“红色的郁金香”,它能直接在图中框出所有红色郁金香的位置——这就是多模态目标检测:结合图像视觉信息和文本语义信息,同时完成“是什么”(分类)和“在哪里”(定位)的任务。传统目标检测(如YOLOv5、YOLOv8)只能识别预定义的类别(比如训练时学过“猫”“狗”),但多模态目标检测摆脱了“类别预定义”的限制,只要文本能描述,它就能检测,这就是“开放词汇检测(Open-Vocabulary Detection)”的魅力。

know_F0727的博客 204

[LeetCode] Longest Palindrome Substring 详细分析

Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring. 面DP题的考官都是神经病。。(吐

jhbxlx的专栏 1860

mongodb在游戏开发领域的优势

目前游戏服务器使用mysql作为数据库的较多,然而,使用mongodb来作为存储层,在某些方面比mysql更为方便和适合。

littleschemer的博客 1698

R语言中5种正态性检验的方法

统计学中的t检验和方差分析等方法的应用条件是样本都来自正态总体或近似正态总体,只有符合这个条件,才能用这些方法来检验各样本所属的总体参数的差异显著性。文本向大家介绍在R语言中检验正态性的几种方法: 1、Kolmogorov-Smirnov检验 K-S检验检验单一样本是否来自某一特定分布。比如检验一组数据是否为正态分布。它的检验方法是以样本数据的累积频数分布与特定理论分布比较,若两者间的差距很小,则推论该样本取自某特定分布族。K-S检验的原假设和备择假设为: H0:样本所来自的总体分布服从

Mrrunsen的博客 2万+

leetcode-第五题-longestPalindrome

package com.freshbin.leetcode.from1to100.medium; import java.util.HashMap; import java.util.Map; /** * 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 * 示例 1: * 输入: "babad" * 输出: "bab" * 注意: "aba...

freshbin000的博客 420

使用Clumsy和Process Explorer定位软件高CPU占用问题

使用弱网模拟工具Clumsy和进程查看工具Process Explorer定位软件高CPU占用问题。

dvlinker的技术专栏 5706

leetcode力扣刷题报告 5 Longest Palindromic Substring 最长回文子串

动态规划 leetcode解题

weixin_41147129的博客 181

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

LeetCode5 最长回文子串 Longest Palindromic Substring

LeetCode5 最长回文子串 Longest Palindromic Substring 题目描述 题目地址:https://leetcode-cn.com/problems/longest-palindromic-substring/solution/ 题目难度:中等 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 示例1: 输入: "bab...

沙码龙 323

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LeetCode 5. Longest Palindromic Substring 最长回文子串 C#

前言 本文介绍了 LeetCode 第 5 题 , “Longest Palindromic Substring”, 也就是 “最长回文子串” 的问题. 本文使用 C# 语言完成题目,介绍了 中心扩展法、马拉车算法 等 多种方法供大家参考。 题目 English LeetCode 5. Longest Palindromic Substring Given a string s, find th...

wf824284257的博客 751

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

【LeetCode】5. Longest Palindromic Substring 最长回文子串

【LeetCode】5. Longest Palindromic Substring 解题报告(Python) 标签: LeetCode 题目地址:https://leetcode.com/problems/longest-palindromic-substring/description/ 题目描述: Given a string s, find the longest palind...

负雪明烛 7775

LeetCode 5. Longest Palindromic Substring (最长回文子串)

题目描述: 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为1000。   示例1: 输入: "babad" 输出: "bab" 注意: "aba"也是一个有效答案。 示例2: 输入: "cbbd" 输出: "bb"   Accepted C++ Solution:   1. 改进的中心扩展方法: 将原字符串扩展成#a#b#c#的形式可以直接...

amoscykl的博客 537

【leetcode】-5. Longest Palindromic Substring求最长回文子串

Longest Palindromic Substring题目动态规划python代码 题目 Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: “babad” Output: “bab” Note: “aba” is also a valid answer. Example 2: Input:

。 331

LeetCode 第5题 Longest Palindromic Substring 最长回文子串

  这道题实在是很经典了,解法也很多,我只写出了暴力解法-_-||,功力不够啊,把这些解法都学会总结一下,看看是怎么一步一步优化过来的。 题目描述   给定一个子串,找出其中最长的回文子串,注意子串一定要是连续的。 题目解法 暴力解法   我的暴力解法思路很简单,从大到小枚举可能的长度(len,1)(len,1)(len,1),然后对每个长度枚举起点,然后判断枚举是否为回文串,如果是则终止枚举然后...

XiangJiaoJun_的博客 368

Leetcode 5.最长回文子串(Longest Palindromic Substring)

Leetcode 5.最长回文子串 1 题目描述(Leetcode题目链接)   给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。示例: 输入: "babad" 输出: "bab" 注意: "aba" 也是一个有效答案。 2 题解   本题可以使用动态规划的方法,子串不是子序列,需要连续,因此可以定义DP[i][j]DP[i][j]DP[i][j]为字符i...

qq_39378221的博客 430

LeetCode 5. 最长回文子串(Longest Palindromic Substring)

LeetCode.jpg 5. 最长回文子串 5. 最长回文子串 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 1: 输入: "babad" 输出: "bab" 注意: "aba" 也是一个有效答案。 示例 2: 输入: "cbbd" 输出: "bb" 切题 一、Clarification 求最长回文子串,这里有几个特殊情况...

墨1024 302

【小白爬Leetcode5】最长回文子串 Longest Palindromic Substring

【小白爬Leetcode5】最长回文子串 Longest Palindromic Substring 题目Manacher算法 O(n) 题目 Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Manacher算法 O(n) Manacher算法可以在O(n) 的时间内求以每个字母为回文中心的最大回文子串的长度,然后再从这里面

weixin_41604040的博客 241

LeetCode 5. Longest Palindromic Substring 最长回文子串(Java)

题目: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: “babad” Output: “bab” Note: “aba” is also a valid answer. E...

qq_41878358的博客 282

leetcode5. Longest Palindromic Substring最长回文子串多种解法-待补充

原题链接 题目的意思不过多的赘述,这里先给出三种解法:暴力解,马拉车,一种巧解 暴力解 写一个判断回文的函数,两重循环判断最长子串(这种方法在字符串过长时可能会栈溢出) class Solution: def longestPalindrome(self, s: 'str') -&amp;amp;gt; 'str': if len(s) &amp;amp;lt; 2: return...

weixin_42156928的博客 207

【Leetcode-python】5.Longest Palindromic Substring(最长的回文子串)

题目:给定一个字符串s,找到它的最长的回文子串。假设s的最大长度为1000。 例:Input: "babad" Output: "bab"Note: "aba" is also a valid answer. Input: "cbbd" Output: "bb" 回文字符串就是指前后是对称的字符串。 需要考虑的特殊情况: 1.Input: ""Output: "" ;...

vita2dolce的博客 222
上一篇: 547. Friend Circles(朋友圈)
下一篇: leetcode 416. Partition Equal Subset Sum(分割等和子集)
蓝羽飞鸟
博客等级 码龄8年 1万+粉丝 727原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蓝羽飞鸟

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值