当前位置:网站首页>Daily question 2 12
Daily question 2 12
2022-07-05 02:50:00 【mujiaoniao】
I'm not alone
Catalog
Lee_3: Longest character :
The idea of sliding windows , Ensure that the characters in the window meet the requirements of the topic , Reject the non-conforming questions directly
public int lengthOfLongestSubstring(String s) {
// The longest substring without repetition
int len = s.length();
if (len == 0 ) return 0;
Map<Character,Integer> map = new HashMap<>();
int max = 0;
int left = 0;
for (int i = 0; i < len; i++) {
if (map.containsKey(s.charAt(i))){
left = Math.max(left,map.get(s.charAt(i))+1);
}
map.put(s.charAt(i),i);
// Store the value of the subscript .
max = Math.max(max,i-left+1);// Through constant progress on left Subscript control Eliminate the existing characters ;
}
return max;
}边栏推荐
- 问下,这个ADB mysql支持sqlserver吗?
- Design and implementation of campus epidemic prevention and control system based on SSM
- Can you really learn 3DMAX modeling by self-study?
- El select, El option drop-down selection box
- Asynchronous and promise
- openresty ngx_ Lua execution phase
- Design and implementation of kindergarten management system
- 【LeetCode】222. The number of nodes of a complete binary tree (2 mistakes)
- Tiny series rendering tutorial
- this+闭包+作用域 面试题
猜你喜欢

Hot knowledge of multithreading (I): introduction to ThreadLocal and underlying principles

【LeetCode】501. Mode in binary search tree (2 wrong questions)

Linux安装Redis

Azkaban实战

openresty ngx_lua执行阶段

Asynchronous and promise

Privatization lightweight continuous integration deployment scheme -- 01 environment configuration (Part 1)

单项框 复选框

Azkaban actual combat
![Hmi-31- [motion mode] solve the problem of picture display of music module](/img/9c/0b25c0a41758652848aed2a269880f.jpg)
Hmi-31- [motion mode] solve the problem of picture display of music module
随机推荐
2021 Li Hongyi machine learning (2): pytorch
低度酒赛道进入洗牌期,新品牌如何破局三大难题?
Asp+access campus network goods trading platform
The most powerful new household god card of Bank of communications. Apply to earn 2100 yuan. Hurry up if you haven't applied!
Why is this an undefined behavior- Why is this an undefined behavior?
[daily problem insight] Li Kou - the 280th weekly match (I really didn't know it could be so simple to solve other people's problems)
GFS distributed file system
【LeetCode】110. Balanced binary tree (2 brushes of wrong questions)
Sqoop命令
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience
Redis distributed lock, lock code logic
Why do you understand a16z? Those who prefer Web3.0 Privacy Infrastructure: nym
Zabbix
PHP cli getting input from user and then dumping into variable possible?
Azkaban installation and deployment
1.五层网络模型
Cut! 39 year old Ali P9, saved 150million
Azkaban actual combat
Eight days of learning C language - while loop (embedded) (single chip microcomputer)
ELFK部署