当前位置:网站首页>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;
}
边栏推荐
- Kotlin - coroutine
- openresty ngx_lua执行阶段
- Spark SQL learning bullet 2
- Zabbix
- Exploration of short text analysis in the field of medical and health (I)
- 【LeetCode】106. Construct binary tree from middle order and post order traversal sequence (wrong question 2)
- The phenomenology of crypto world: Pioneer entropy
- 【LeetCode】111. Minimum depth of binary tree (2 brushes of wrong questions)
- Vb+access hotel service management system
- Eight days of learning C language - while loop (embedded) (single chip microcomputer)
猜你喜欢
Azkaban overview
Design and implementation of campus epidemic prevention and control system based on SSM
Linux Installation redis
2021 Li Hongyi machine learning (2): pytorch
Watch the online press conference of tdengine community heroes and listen to TD hero talk about the legend of developers
Master Fur
1.五层网络模型
Avoid material "minefields"! Play with super high conversion rate
Tencent cloud, realize image upload
Azkaban安装部署
随机推荐
GFS distributed file system
Hmi-30- [motion mode] the module on the right side of the instrument starts to write
Eight days of learning C language - while loop (embedded) (single chip microcomputer)
Vb+access hotel service management system
2022/02/13
How to make OS X read bash_ Profile instead of Profile file - how to make OS X to read bash_ profile not . profile file
低度酒赛道进入洗牌期,新品牌如何破局三大难题?
SFTP cannot connect to the server # yyds dry goods inventory #
Avoid material "minefields"! Play with super high conversion rate
Pytest (4) - test case execution sequence
【微服务|SCG】Filters的33种用法
Design and implementation of kindergarten management system
Acwing game 58 [End]
LeetCode --- 1071. Great common divisor of strings problem solving Report
Azkaban overview
Sqoop installation
Problem solving: attributeerror: 'nonetype' object has no attribute 'append‘
Day_ 17 IO stream file class
Watch the online press conference of tdengine community heroes and listen to TD hero talk about the legend of developers
Devtools的简单使用