LeetCode.3-最长无重复字符子串(Longest Substring Without Repeating Characters)

深度学习驱动的中华白海豚个体识别:背鳍检测与特征匹配实战 在野外生物多样性监测中,个体识别是种群动态研究的基石。传统人工比对依赖经验且效率低下,基于深度学习的目标检测与特征提取技术,为照片个体识别提供了可复现的算法方案。通过背鳍检测(如YOLO)定位关键区域,再利用度量学习(如Triplet Loss)将背鳍图像映射为特征向量,最终以最近邻匹配完成个体身份确认。这项技术已应用于中华白海豚等海洋哺乳动物的照片识别,极大提升了处理效率与准确率。本文从方案选型、数据标注、训练配置到推理部署,给出了完整实践思路与常见坑的排查方法。 阅读详情

这是悦乐书的第341次更新,第365篇原创

01 看题和准备

今天介绍的是LeetCode算法题中Medium级别的第2题Longest Substring Without Repeating Characters(顺位题号是3)。给定一个字符串,找到最长无重复字符子字符串的长度。例如:

输入:“abcabcbb”
输出:3
说明:答案是“abc”,长度为3。

输入:“bbbbb”
输出:1
说明:答案是“b”,长度为1。

输入:“pwwkew”
输出:3
说明:答案是“wke”,长度为3。请注意,答案必须是子字符串,“pwke”是子序列而不是子字符串。

02 第一种解法

暴力解法,使用双指针和HashSet。

每次选取一个字符,从该字符开始往后遍历,存入HashSet中去,借助HashSet来判断是否重复出现,如果遇到重复字符,就结束循环,计算起始索引的长度,然后将HashSet清空,继续循环,再从第二个字符开始遍历,直到处理完所有字符。

此解法的时间复杂度是O(N^2),最坏情况下时间复杂度是O(N^3),因为HashSet的contains方法;空间复杂度是O(N)。

public int lengthOfLongestSubstring(String s) {
    Set<Character> set = new HashSet<Character>();
    int n = s.length(), left = 0, right = 0;
    int result = 0;
    for (int i=0; i<n; i++) {
        left = i;
        right = i;
        while (right < n && !set.contains(s.charAt(right))) {
            set.add(s.charAt(right));
            right++;
        }
        result = Math.max(result, right-left);
        set.clear();
    }
    return result;
}

03 第二种解法

针对第一种解法,我们还可以将HashSet换成数组,用数组来判断字符是否重复出现,其他思路一样。

public int lengthOfLongestSubstring2(String s) {
    int[] set = new int[256];
    int n = s.length(), left = 0, right = 0;
    int result = 0;
    for (int i=0; i<n; i++) {
        left = i;
        right = i;
        while (right < n && ++set[s.charAt(right)] < 2) {
            right++;
        }
        result = Math.max(result, right-left);
        // 将数组元素值全部重置为0
        Arrays.fill(set, 0);
    }
    return result;
}

04 第三种解法

滑动窗口算法。

此解法和上面的第一种解法有点类似,使用两个变量,一左一右,像窗口一样滑动,遇到重复值时,就将左边的一个字符从HashSet中移除,直到遍历完所有字符。

此解法的时间复杂度是O(N),最坏情况下时间复杂度是O(N^2),因为HashSet的contains方法;空间复杂度是O(N)。

public int lengthOfLongestSubstring3(String s) {
    Set<Character> set = new HashSet<Character>();
    int n = s.length(), left = 0, right = 0;
    int result = 0;
    while (left < n && right < n) {
        if (!set.contains(s.charAt(right))) {
            set.add(s.charAt(right));
            right++;
            result = Math.max(result, right-left);
        } else {
            set.remove(s.charAt(left));
            left++;
        }
    }
    return result;
}

05 第四种解法

使用索引值来判断,同时将HashSet换成256大小的数组。

public int lengthOfLongestSubstring4(String s) {
    int[] set = new int[256];
    int n = s.length(), i = 0, j = 0;
    int result = 0;
    while (i < n && j < n) {
        i = Math.max(set[s.charAt(j)], i);
        result = Math.max(result, j-i+1);
        set[s.charAt(j)] = j+1;
        j++;
    }
    return result;
}

06 小结

算法专题目前已连续日更超过六个月,算法题文章210+篇,公众号对话框回复【数据结构与算法】、【算法】、【数据结构】中的任一关键词,获取系列文章合集。

以上就是全部内容,如果大家有什么好的解法思路、建议或者其他问题,可以下方留言交流,好看、留言、转发就是对我最大的回报和支持!

全面解析量化价值投资多因子模型的原理 明明知道“买便宜的好公司”是价值投资的核心,但面对3000+只A股,如何快速筛选出“便宜又好”的标的?主观判断总被情绪干扰——明明PE很低的股票,买了却不涨;或者因为“感觉”错过牛股?想规模化投资,但手动分析100只股票就要花一周,根本无法覆盖全市场?量化价值投资的多因子模型,正是解决这些问题的钥匙。它将价值投资的核心逻辑(“便宜”“好公司”)转化为可量化的因子,用数学模型替代主观判断,实现系统化筛选、可回测验证、规模化复制的投资决策。为什么多因子模型能有效预测股票收益? 阅读详情

相关推荐

Anasys Workbanch实战解析:齿轮接触强度有限元分析全流程

本文详细解析了在Anasys Workbanch中进行齿轮接触强度有限元分析的全流程。从模型简化、材料赋予、接触对设置,到网格划分艺术、非线性接触求解调试,再到结果后处理与工程解读,提供了避开常见陷阱的实战经验,旨在帮助工程师精准评估齿轮强度与疲劳寿命。

weixin_29209805的博客 354

leetcood-3无重复字符的最长子串

class Solution { public: int lengthOfLongestSubstring(string s) { int max=0,flage=0; int i,j; for(i=0;i<s.size();i++){//每个字符开始遍历 for(j=flage;j<i;j++){//遍历...

u014157968的博客 233

C#通过Aforge调用电脑摄像头(附代码)

C#标准库本身不带有能调用电脑摄像头的库,如果利用windows自身的API来实现的话,着实有些麻烦。Aforge这个第三方库能很好的实现调用、处理的功能。 PS:文末给大家分享了完整的项目源码,各位最好先下载下来,对照着来看 1、先看一下效果 2、Aforge介绍 AForge.NET是一个专门为开发者和研究者基于C#框架设计的,这个框架提供了不同的类库和关于类库的资源,还有很多应用程序例子,包括计算机视觉与人工智能,图像处理,神经网络,遗传算法,机器学习,机器人等领域。 3、我使用的开发环境 操作系统

weixin_44996090的博客 1万+

leetcood学习笔记-3-无重复字符的最长子串

题目描述: 方法一: class Solution: def lengthOfLongestSubstring(self, s: str) -> int: slow = 0 fast = 0 res_max = 0 table = dict() while slow<le...

weixin_30454481的博客 159

PyTorch实战:手把手教你用QAT量化感知训练拯救模型精度(附避坑指南)

本文详细介绍了如何使用PyTorch进行QAT量化感知训练,以提升模型在边缘设备上的推理精度。通过核心原理讲解、实战代码示例和避坑指南,帮助开发者掌握从环境配置、模型训练到边缘部署的全流程,有效解决传统量化方法导致的精度损失问题。

c7d8e的博客 335

从单机到多机:用llama.cpp的RPC模式榨干你闲置的GPU(附性能调优参数)

本文详细介绍了如何利用llama.cpp的RPC模式实现多机部署,将闲置GPU资源整合为高效推理集群。通过实战案例展示了性能调优参数设置、端口分配策略以及常见问题排查技巧,帮助中小团队最大化利用异构GPU设备,提升文本摘要等任务的推理效率。

weixin_27240351的博客 606

【Java】【LeetCode】3. Longest Substring Without Repeating Characters 最长无重复字符的子串

这道求最长无重复子串的题和之前那道Isomorphic Strings很类似,属于LeetCode的早期经典题目,博主认为是可以跟Two Sum媲美的一道题。给了我们一个字符串,让我们求最长的无重复字符的子串,注意这里是子串,不是子序列,所以必须是连续的。我们先不考虑代码怎么实现,如果给一个例子中的例子"abcabcbb",让你手动找无重复字符的子串,该怎么找。博主会一个字符一个字符的遍历,比...

zhelong19830726的博客 275

基于MATLAB/Simulink与WSL2的ROS2实时联合仿真实践

本文详细介绍了基于MATLAB/Simulink与WSL2的ROS2实时联合仿真实践。通过环境配置、PX4仿真环境搭建、自定义消息生成、Simulink通信实现及实时优化等步骤,提供了完整的无人机位置控制案例,帮助开发者实现高精度的实时联合仿真。

red88的博客 212

[LeetCode]3. Longest Substring Without Repeating Characters寻找最长无重复字符的子串

Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3....

diaobi8410的博客 112

关于42步进电机驱动——基于STM32 HAL库实现

我找了好多资料,好多关于42步进电机的都是文档,这么文档都需要积分,需要积分就算了内容还非常差,浪费时间和电脑的内存。关于大部分是基于Arduino和51去驱动的 42步进电机驱动硬件如下: 首先你要了解步进电机的驱动原理,我也不啰嗦了,请看这边博客: 二相四线,四相五线,四相六线步进电机接线及驱动方法 , 看完这篇你就知道驱动和接线的原理了。 起初我也为如何接线烦恼,因为有些博客在讲述这些问题的时候没有讲的很透彻。 方法如下: ①用万用表调到欧姆档,用其中一个表笔搭在一个引脚上,依次测其它.

Jodan132的博客 1万+

DeerFlow 系列教程 第十六篇 | 实战案例一——用 DeerFlow 进行深度研究

在日常使用 AI Agent 时,最常见的需求之一就是对某个主题进行全面、系统的研究。多源信息采集——不能只依赖单次搜索,需要从多个角度搜索不同来源交叉验证——不同来源的信息需要相互印证,避免单一信源的偏差结构化输出——最终产出的不是零散的信息片段,而是有组织的研究报告传统做法是人工反复搜索、阅读、整理。传统手工研究: DeerFlow 深度研究:人工搜索 → 阅读页面 → 记笔记 提交研究主题│ │▼ ▼换关键词 → 再搜索 → 再阅读 ┌──────────────────┐。

weixin_43674738的博客 178

LeetCode-3:Longest Substring Without Repeating Characters (最长无重复字符的子串) --medium

给定一个字符串,从中找出不含重复字符的最长子串的长度

大树先生的博客 1659

倍福---EL2262模块飞拍配置

控制器安装了twincat3,用EL2262实现相机飞拍功能。本文档只介绍如何通过EL2262实现飞拍的触发,并不涉及视觉方面的处理 参考文章: https://author.baidu.com/home?from=bjh_article&app_id=1669190598708386 https://mp.weixin.qq.com/s/r4Iq8kOP-o4_M8vCce5M9g 1、 飞拍的应用 在大多数场合,只能当被检测工件和相机都处于静止状态下才能进行拍照,拍照完成后,再移动工件或相机,进

weixin_41883890的博客 3754

小白水平理解面试经典题目LeetCode 3 Longest Substring Without Repeating Characters(最长无重复字符的子串)

作为leetcode第三道题,类型是典型的String类型,都可以让我们联想到Two pointer, 暴力解法,就让我们看看这道题如何解答更好。

心安成长的码字书房 544

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

LeetCode-3:Longest Substring Without Repeating Characters (最长无重复字符的子串)

题目: Given a string, find the length of the longest substring without repeating characters. 例子: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", wit...

Never-Giveup的博客 212

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

leetcode-3:Longest Substring Without Repeating Characters 最长无重复字符的子串

题目: Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3....

别说话写代码的博客 277

深度学习工具包 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&#39;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(&#39;DeepLearnToolbox&#39;));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(&#39;state&#39;,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&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,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 = &#39;sigm&#39;;%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, &#39;Too big error&#39;);```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(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;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)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;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, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% 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&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 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, &#39;Too big error&#39;);```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(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,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, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % 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, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);%% 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(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % 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, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

[LeetCode] [C++] LeetCode 3 Longest Substring Without Repeating Characters 最长无重复字符子串...

题目要求 Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the length is 3. Given "bbbbb", the answer is "b", ...

weixin_30716725的博客 99

【算法——Python实现】滑动窗口解决数组问题

滑动窗口思路: 解决部分数组问题时,设置两个索引下标i,j,i为左边界,j为右边界,逐渐遍历整个数组,i和j组成的子数组形成长度变化的滑动窗口,直至i遍历完整个数组。应用一: Leetcode 209:Minimum Size Subarray Sum 给定一个整型数组和一个数字s,找到数组中最短的一个连续子数组,使得连续子数组的数字和sum>=s,返回这个最短的连续子数组的长度值class

Fire_KAKA的博客 1万+

LeetCode第3题 无重复字符的最长子串(Longest Substring Without Repeating Characters)

文章目录题目地址题目描述代码实现 题目地址 题目地址https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ 题目描述 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其...

ThinkWon的博客 6989

LeetCode 3.Longest Substring Without Repeating Characters 无重复字符的最长子串

题目描述 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: “abcabcbb” 输出: 3 解释: 因为无重复字符的最长子串是 “abc”,所以其长度为 3。 示例 2: 输入: “bbbbb” 输出: 1 解释: 因为无重复字符的最长子串是 “b”,所以其长度为 1。 示例 3: 输入: “pwwkew” 输出: 3 解释: 因为无重复字符的最长子串是 “w...

it-hao的博客 2559

LeetCode 3 — Longest Substring Without Repeating Characters (C++ Java Python)

题目:http://oj.leetcode.com/problems/longest-substring-without-repeating-characters/] Given a string, find the length of the longest substring without repeating characters. For example, the longest sub

龙之梦 5813

【Leetcode】Longest Substring Without Repeating Characters

题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/ 题目: Given a string, find the length of the longest substring without repeating characters. Examples: Give

业精于勤,荒于嬉 3185

[LeetCode]3. 无重复字符的最长子串(Longest Substring Without Repeating Characters)题解

在leetcode中该题网址:https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/ 题目描述: 给定一个字符串,请你找出其中不含有重复字符的 最长子串 的长度。 示例 1: 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 ...

sultry_yi的博客 524

Leetcode 3 Longest Substring Without Repeating Characters

Leetcode 3 Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: Th...

博学 笃志 切问 近思 162

[LeetCode] Longest Substring Without Repeating Characters 最长无重复字符的子串

题目 Given a string, find the length of the longest substring without repeating characters. Example 1: Input: “abcabcbb” Output: 3 Explanation: The answer is “abc”, with the length of 3. Example 2: Inpu...

Deephome的博客 222

【LeetCode】3、Longest Substring Without Repeating Characters(最长子串)

【LeetCode】3、Longest Substring Without Repeating Characters(最长子串) 1、题目描述 Given a string s, find the length of the longest substring without repeating characters. 找给定字符串中,最长的无重复字符的子串 做题过程: 当时题目理解错了,瞎鸡儿敲了敲,卒。 看答案!!! 2、暴力解法 其实最开始我敲的过程中有点像暴力解法,暴力解法就是莽。 两次循环把串中

Zangjiji的博客 229
上一篇: LeetCode.2-两个数字相加(Add Two Numbers)
下一篇: LeetCode.5-最长回文子串(Longest Palindromic Substring)
程序员小川
博客等级 码龄10年 47粉丝 305原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址