5、最长回文子串

【Leetcode】5. 最长回文子串 给你一个字符串s,找到s中最长的回文子串。解释:“aba” 同样是符合题意的答案。 阅读详情

1、题目

给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为1000。

示例 1:
输入: “babad”
输出: “bab”
注意: "aba"也是一个有效答案。

示例 2:
输入: “cbbd”
输出: “bb”

2、解法:

@1动态规划法:

  • 思路:子串本身正着读、反着读都一样,比如“aba”,而“abcfgcba”,虽然abc相同,但是它们不是同一子串。
    例如“abaaba”,只要aa内部对称,外部ab、ba也对称,那么整个都是回文子串。

  • 从确定1子串
    在这里插入图片描述
    2子串
    在这里插入图片描述
    3子串…n子串(这种方法不适用2子串,是因为[i+1,j-1]的范围)
    在这里插入图片描述

class Solution {
   public String longestPalindrome(String s) {
       // 如果是空子串
       if (s.equals("")) {
           return "";
       }

       int start = 0, longest = 1;
       // 创建2维数组,用来记录
       int len = s.length();
       int[][] arr = new int[len][len];
       char[] sr = s.toCharArray();

       for (int i = 0; i < len; i++){
           // 1子串
           arr[i][i] = 1;
           if (i < len-1) {
               if (sr[i] == sr[i+1]) {
               // 2子串
                arr[i][i+1] = 1;
                start = i;
                longest = 2;
                }
            }    
       }

       // 3子串...length子串
       for (int n = 3; n <= len; n++) {
           for (int i = 0; (i+n-1) < len; i++) {
               if (sr[i] == sr[i+n-1] && arr[i+1][i+n-2] == 1) {
                   arr[i][i+n-1] = 1;
                   start = i;
                   longest = n;
               }
           }
       }
        return s.substring(start, start + longest);
    }
}

时间复杂度O(n^2) ,空间复杂度O(n^2)

力扣5. 最长回文子串C++详解 力扣5. 最长回文子串 注:子数组或者子字符串求解问题一般基本是用DP算法 最长回文子串的解释:正着读和反着读是一样的。 题目解析: 解法一:动态规划 从回文子串的定义我们可以得出两个结论: (1)如果说一个子字符串是回文子串,那么给这个子字符串两边分别加一个数,如果这2个数相等,那么这个新的子字符串也是回文子串。 (2)回文子串的开始和结束位置的字符一定是相... 阅读详情

相关推荐

LeetCode 5 最长回文子串

题目 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 思路 一眼看上去就是动态规划,当然还有更快的方法,详见Manacher算法。 动态规划步骤 确定状态空间 确定状态转移函数,子状态的关系 遍历状态空间,填状态标注 得到结果 状态压缩,优化算法 本题思路 1. 确定状态空间 string s中的最长回文子串即确定s[i:j]是否是回文子串和回文串...

梦中随笔 299

LeetCode5.最长回文子串 JavaScript

LeetCode5.最长回文子串 JavaScript 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 1: 输入: “babad” 输出: “bab” 注意: “aba” 也是一个有效答案。 示例 2: 输入: “cbbd” 输出: “bb” /** * @param {string} s * @return {string} */ ...

weixin_40659167的博客 608

LeetCode 5 - 最长回文子串

是一到算法经典题目,考察字符串的基本操作、动态规划、中心扩展等常用技巧,能够有效提升对字符串问题的综合解题能力。以下是详细解析几种主流解法,以及经典的变体问题和对应解决思路。ssn2 * n - 1nn-1dp[i][j]s[i..j]s[i..j]j - i <= 2j - i > 2lManacher 算法是一种优化的解决回文子串问题的线性算法,通过预处理字符串和利用回文的对称性将时间复杂度降低到 O(n)。

互联网架构师笔记 1018

【LeetCode-5】最长回文子串

【LeetCode-5】最长回文子串题目测例思路解题思路易错点代码感想 题目 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 链接:最长回文子串 测例 输入:“babad” 输出:“bab” 注意:“aba” 也是一个有效答案。 思路 解题思路 一看就是个动态规划题,1个字母的时候最大长度是1,两个字母的时候只需要比较他们是否相等,3个字母的时候比较首尾是否相等,4个字母比较首位是否相等,然后再比较中间两个是否相等。而中间两位是否相等在2个字母的时候已经比较过了

qq_40560275的博客 185

DRAM自测试模块

1 背景技术DDR3/4 SDRAM属于高速外设,最高时钟频率可达到1600MHz,最高速率可达3200MT/s。在存储控制器与DDR34 SDRAM设备之间有一层专为高速接口设计的模拟电路,此电路对于前端设计人员来说,不管在模拟验证阶段和回片测试阶段,都是一个黑盒子。而对于后端测试人员来说若此部分为外购IP,则内部结构也是无法清楚了解的。所以在测试阶段,对于DDR34 SDRAM的测试就具有一定的

Hierro的DDR世界 7015

小鹏P7车载以太网诊断实战:从OBD口定义到DoIP协议验证

本文详细解析了小鹏P7车载以太网诊断的实战过程。从OBD接口的针脚定义入手,依据ISO13400标准,确认了以太网线对位置,并指导制作专用的RJ45转OBD线束。通过搭建测试环境,使用Ping、端口扫描及Wireshark抓包,最终成功验证了车辆对DoIP协议的支持,为基于以太网的高速诊断与刷写提供了完整的技术路径。

CAT789的专栏 530

5最长回文子串

一、前言 标签:动态规划、中心扩散。 问题来源LeetCode 5 难度:中等。 问题链接:https://leetcode-cn.com/problems/longest-palindromic-substring/ 二、题目 给定一个字符串s,找到s中最长的回文子串。你可以假设s的最大长度为 1000。 示例1: 输入: "babad" 输出: "bab" 注意: "aba" 也是一个有效答案。 示例2: 输入: "cbbd" 输出: "bb" 三、思路...

行走 195

手把手教你用FPGA实现SGMII接口:从IP核配置到板级调试全流程

本文详细介绍了如何在Xilinx 7系列FPGA上实现SGMII(Serial Gigabit Media Independent Interface)接口的全流程,包括IP核配置、约束编写和硬件调试。通过具体的硬件选型建议、软件工具链配置和PCB设计规范,帮助开发者快速构建稳定可靠的千兆通信链路,并提供了常见故障排查和性能优化技巧。

weixin_29194693的博客 298

LeetCode5.最长回文子串

LeetCode5.最长回文子串 问题 分析 解法一:中心扩散法 顾名思义就是每一个位置中心去扩散,去找回文串,遇到不是回文串的时候结束。 寻找方法就是首先先找其左边和右边位置,如果相等即继续走,只到走到左边的值和右边的值都不和中间元素相等,然后判断左右值是否相等。 解法二:动态规划 ​ 回看中心扩展算法,其实中间做了很多重复的计算,而动态规划就是为了减少重复计算的问题。即以空间换时间,将计算结果暂时存放起来,以避免重复计算 使用boolean dp[l] [r]表示字符串l到r这段是否是回文串,如果

冢狐的私人空间 2379

手把手教你学simulink实例--基于Simulink的航空发动机控制系统设计与仿真

航空发动机是飞机的核心动力装置,其性能直接影响飞行器的安全性、经济性和可靠性。现代航空发动机控制系统需要具备高精度、快速响应和强鲁棒性的特点,以适应复杂的飞行环境和任务需求。本项目旨在使用MATLAB/Simulink平台,设计并实现一种适用于涡扇发动机的闭环控制系统,通过调节燃油流量、压气机叶片角度等控制变量,确保发动机在不同工况下稳定运行,并满足推力需求。

MHD0815的博客 278

yolov5运行detect.py之后卡住了?没后续,没结果,没报错,怎么办?如何解决?

🏆 本文收录于《全栈Bug调优(实战版)》专栏,致力于分享我在项目实战过程中遇到的各类Bug及其原因,并提供切实有效的解决方案。无论你是初学者还是经验丰富的开发者,本文将为你指引出一条更高效的Bug修复之路,助你早日登顶,迈向财富自由的梦想🚀!同时,欢迎大家关注、收藏、订阅本专栏,更多精彩内容正在持续更新中。让我们一起进步,Up!Up!Up!    备注: 部分问题/难题源自互联网,经过精心筛选和整理,结合数位十多年大厂实战经验资深大佬经验总结所得,数条可行方案供所需之人参考。

**My Coding Family** 1106

leetcode 5. 最长回文子串

@(labuladong的算法小抄)[dp, 双指针] leetcode 5. 最长回文子串 题目描述 解题思路 参考:labuladong的算法小抄P373 dp 时间o(n²),空间o(n²) 注意与最长回文子序列解法的区别。子串必须要求是连续的,因此,如果定义dp[i][j]表示s[i...j]最长回文子串的长度,则由dp[i+1][j-1]无法推出dp[i][j] class Solution { public String longestPalindrome(String s) {

Charison的编程妙妙屋 527

MATLAB - Gazebo 联合仿真 —— 使用 UR10 机械臂检测和采摘水果

本示例演示如何在 Gazebo 物理模拟器中设置 Universal Robotics UR10 机械臂和仿真环境。您需要配置一个机器人从树上摘苹果的仿真环境。本示例演示如何利用这些工具箱,使用 Universal Robotics UR10 机械手模拟机器人检测并从树上摘取苹果。Robotics System Toolbox™ - 在 Simulink® 和 Gazebo 中对机械手进行建模、规划和模拟。Navigation Toolbox™ - 生成三维环境的占用图。

机器人控制与仿真应用 4186

算法:leetcode_5_最长回文子串

摘要:本文介绍了两种求解最长回文子串的方法:动态规划和中心扩散法。动态规划通过构建二维dp表记录子串状态,从下到上、从左到右遍历字符串,时间复杂度较高但思路清晰。中心扩散法则以每个字符(或相邻字符对)为中心向两边扩展寻找回文,更高效且代码简洁。

bugMaker_0621的博客 1071

11、牛转录组分析的实用生物信息学流程

本文详细介绍了一套实用的牛转录组分析生物信息学流程,涵盖从数据提取、基因组索引生成、读取比对到单样本表达分析及差异表达分析的完整步骤。使用Angus和Brahman牛的RNA-seq数据作为示例,介绍了HTSEQ、featureCounts和StringTie等工具在基因表达计数中的应用,并结合edgeR和limma进行差异表达分析。文中提供了详细的命令行与R代码示例,包含常见问题解答与关键注意事项,帮助研究人员高效、准确地完成转录组数据分析。

ios99的博客 112

概念解析 | 雷达动态范围

这里存在一个动态范围的问题:强雷达发射信号和弱目标反射信号存在非常大的功率差异,比如传统的脉冲多普勒雷达动态范围可达90dB以上。随着上述技术的发展,预计未来十年雷达接收机动态范围将达到120dB以上,届时雷达的监视能力将得到极大增强。简单来说,雷达动态范围越大,表示接收机噪声越低,对强信号过载保护能力越强,就越能检测到弱信号目标。此外,部分新概念雷达对动态范围提出新的需求,如被动雷达动态范围需大于100dB。当前,随着阵列雷达和数字雷达技术的发展,对雷达接收机动态范围提出了更高要求。

NLOS的博客 1052

C++算法实现 LeetCode 5. 最长回文子串

C++算法实现 LeetCode 5. 最长回文子串   大家好,我叫亓官劼(qí guān jié ),在优快云中记录学习的点滴历程,时光荏苒,未来可期,加油~博主目前仅在优快云中写博客,唯一博客更新的地址为:亓官劼的博客 ,同时正在尝试在B站中做一些内容分享,B站主页为: 亓官劼的B站主页 本文原创为亓官劼,请大家支持原创,部分平台一直在恶意盗取博主的文章!!! 若需联系博主,可以联系本人微信:qiguanjie2015 给你一个字符串 s,找到 s 中最长的回文子串。 示例 1:

一起加油 1040

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

LeetCode 5最长回文子串

LeetCode 5最长回文子串 题目简述:给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 输入:“babad” 输出:“bab” 输入:“cbbd” 输出:“bb” 思路:枚举字符串的每一个字符依次作为回文串的中心点,从中心点开始向两边扩散,移动过程中对比中心点左右两个字符是否相同或者是否出界,返回回文串的最长长度 当回文子串是奇数时,从i - 1,i + 1开始往两边扩散 当回文子串是偶数时,从i,i + 1开始往两边扩散 以i为

XBlog 167

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

深度学习工具包 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")

【LeetCode5】最长回文子串

LC5.Longest Palindromic Substring 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: &amp;quot;babad&amp;quot; Output: &amp;quot;bab&amp;quot; Note: &am

e31006的博客 256

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

LeetCode 5. 最长回文子串

欢迎来到茶色岛独家岛屿,本期将为大家揭晓LeetCode 5. 最长回文子串,做好准备了么,那么开始吧。

weixin_62275996的博客 612

算法实践:leetcode5 最长回文子串

leetcode5: 最长回文子串 描述 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 样例 输入: "babad" 输出: "bab" 注意: "aba" 也是一个有效答案。 难度 中,动态规划 解法 代码 class Solution { public String longestPalindrome(String s) { ...

matafeiyanll的博客 248

Leetcode 5 最长回文子串

Leetcode 5 最长回文子串 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 1: 输入: “babad” 输出: “bab” 注意: “aba” 也是一个有效答案。 示例 2: 输入: “cbbd” 输出: “bb” 详解: 这道题赵隽面试搜狐焦点的时候遇到了,发现搜狐焦点还是非常喜欢问别人leetcode序号在前边的题目的,这道题的思路是我...

qq_30163473的博客 169

LeetCode_5_最长回文子串

链接 LeetCode_5_最长回文子串 题目 给定一个字符串s,找到s中最长的回文子串。你可以假设s的最大长度为 1000。 示例 1: 输入: "babad" 输出: "bab" 注意: "aba" 也是一个有效答案。 示例 2: 输入: "cbbd" 输出: "bb" 思路 思路一、动态规划 假设字符串("babab")为s, 它的长度为n dp是大小为 n * n 的二维数组, dp[i][j] 表示s[i,j]是否为回文串, 存储true, false ...

AN_ERA的博客 3262

leetcode5.最长回文子串

给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 1: 输入: "babad" 输出: "bab" 注意: "aba" 也是一个有效答案。 示例 2: 输入: "cbbd" 输出: "bb" 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/longest-palindromic-substri...

yyf_blog 570

[LeetCode] 5.最长回文子串

[LeetCode] 5.最长回文子串 文章目录[LeetCode] 5.最长回文子串题目思路动态规划中心扩散法 题目 给定一个字符串 s,找到 s 中最长的回文子串。你可以假设 s 的最大长度为 1000。 示例 1: 输入: "babad" 输出: "bab" 注意: "aba" 也是一个有效答案。 示例 2: 输入: "cbbd" 输出: "bb" 思路 首先依旧讲暴力解法 ...

菠萝盖饭的博客 334
上一篇: 6、z字形变换
下一篇: 8、字符串转换整数 (atoi)
念殊15
博客等级 码龄8年 17粉丝 177原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值