当前位置:网站首页>LeetCode 3. Longest substring without duplicate characters
LeetCode 3. Longest substring without duplicate characters
2022-06-30 02:43:00 【Xiaozhuang】
Hi, Hello everyone , I am Xiaozhuang .
Today's algorithm for punching cards is —— Power button 3. Longest substring without repeating characters
This question is a school call + Social recruitment , Check the algorithm problem with the second highest frequency , The frequency ranking first is the reverse linked list , See the previous article in the official account for a detailed solution .
This question will use 「 Hashtable + The sliding window 」 Realization , Don't talk much , Let's study together ~
One 、Leetcode subject
1、 Title address
2、 Specific topic


Two 、 Implementation code
1、 Ideas : Hashtable + The sliding window
(1) Specific code
/**
* @param {string} s
* @return {number}
*/
// Hashtable + The sliding window
// Time complexity : O(n),n For the string s The length of
// Spatial complexity : O(n), n by map The length of
var lengthOfLongestSubstring = function(s) {
let map = new Map();
let start = 0;
let end = 0;
let max = 0;
while(true) {
if(end >= s.length) {
break;
}
let temp = map.get(s[end]);
//map Does not exist in
if(temp === undefined || temp < start) {
max = Math.max(max, end - start + 1);
}else {//map There is already
start = temp + 1;
}
map.set(s[end], end);
end++;
}
return max;
};
(2) Running results 
3、 ... and 、 Explain the video
Click to see B The station explains the video
Four 、 The supplementary part
Official account :【 Deep drift programmer Xiaozhuang 】: It contains rich learning resources and interview experience ( Not limited to the front end 、java), There are also learning exchange groups to add , In addition, there are leaders of major factories who can exchange and learn together , Progress together ~ Add Xiaozhuang wechat , reply 【 Add group 】, You can join the Internet technology exchange group .
边栏推荐
- 迅為恩智浦iTOP-IMX6開發平臺
- Several key points recorded after reviewing redis design and Implementation
- Network neuroscience——网络神经科学综述
- Unity3D UGUI强制刷新Layout(布局)组件
- 1380. lucky numbers in matrices
- FDA邮件安全解决方案
- Pytorch学习(二)
- Global and Chinese market of Kanban software 2022-2028: Research Report on technology, participants, trends, market size and share
- Differences among digicert, SECTIONO and globalsign code signing certificates
- Jupyter notebook显示k线图集合
猜你喜欢

最小栈详解
![[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation](/img/c3/f9d6399c931a006ca295bb1e3ac427.png)
[论]【DSTG】Dynamic SpatiotemporalGraph Convolutional Neural Networks for Traffic Data Imputation

2. < tag dynamic programming and 0-1 knapsack problem > lt.416 Split equal sum subset + lt.1049 Weight of the last stone II

HTA introductory basic tutorial | GUI interface of vbs script HTA concise tutorial, with complete course and interface beautification

What are the requirements for NPDP product manager international certification examination?

Call collections Sort() method, compare two person objects (by age ratio first, and by name ratio for the same age), and pass lambda expression as a parameter.

学术汇报(academic presentation)/PPT应该怎么做?

Differences among digicert, SECTIONO and globalsign code signing certificates

Traffic, but no sales? 6 steps to increase website sales

论文回顾:Playful Palette: An Interactive Parametric Color Mixer for Artists
随机推荐
迅為恩智浦iTOP-IMX6開發平臺
HTA introductory basic tutorial | GUI interface of vbs script HTA concise tutorial, with complete course and interface beautification
Detailed explanation of minimum stack
Xunwei NXP itop-imx6 development platform
2022护网行动在即,关于护网的那些事儿
VScode如何Debug(调试)进入标准库文件/第三方包源码
Can autojs code be encrypted? Yes, display of autojs encryption skills
代码签名、驱动签名的常见问题解答
银行的理财产品一般期限是多久?
oracle怎么设置密码复杂度及超时退出的功能
CMake教程系列-01-最小配置示例
Playful palette: an interactive parametric color mixer for artists
主流CA吊销俄罗斯数字证书启示:升级国密算法SSL证书,助力我国网络安全自主可控
threejs 镜子案例Reflector 创建镜子+房子搭建+小球移动
What is the difference between a layer 3 switch and a layer 2 switch
Global and Chinese market of mobile commerce solutions 2022-2028: Research Report on technology, participants, trends, market size and share
IBM websphere通道联通搭建和测试
Créer des compétences exquises dans l'éducation des créateurs
并发请求下如何防重复提交
JS advanced -h5 new features