当前位置:网站首页>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;
}
边栏推荐
- When to catch an exception and when to throw an exception- When to catch the Exception vs When to throw the Exceptions?
- Yuan universe also "real estate"? Multiple second-hand trading websites block metauniverse keywords
- 【LeetCode】501. Mode in binary search tree (2 wrong questions)
- 问题解决:AttributeError: ‘NoneType‘ object has no attribute ‘append‘
- Watch the online press conference of tdengine community heroes and listen to TD hero talk about the legend of developers
- [micro service SCG] 33 usages of filters
- 【LeetCode】110. Balanced binary tree (2 brushes of wrong questions)
- How to find hot projects in 2022? Dena community project progress follow-up, there is always a dish for you (1)
- Day_ 17 IO stream file class
- Kotlin - coroutine
猜你喜欢
Linux Installation redis
ELFK部署
Hmi-31- [motion mode] solve the problem of picture display of music module
Asp+access campus network goods trading platform
【LeetCode】404. Sum of left leaves (2 brushes of wrong questions)
Cut! 39 year old Ali P9, saved 150million
看 TDengine 社区英雄线上发布会,听 TD Hero 聊开发者传奇故事
Sqoop命令
Tiny series rendering tutorial
[uc/os-iii] chapter 1.2.3.4 understanding RTOS
随机推荐
Single box check box
Flume configuration 4 - customize mysqlsource
Tencent cloud, realize image upload
Simple use of devtools
ELK日志分析系统
Good documentation
openresty ngx_lua变量操作
Pat class a 1162 postfix expression
this+闭包+作用域 面试题
Qrcode: generate QR code from text
【LeetCode】110. Balanced binary tree (2 brushes of wrong questions)
Chinese natural language processing, medical, legal and other public data sets, sorting and sharing
Android advanced interview question record in 2022
el-select,el-option下拉选择框
Spoon inserts and updates the Oracle database, and some prompts are inserted with errors. Assertion botch: negative time
Hot knowledge of multithreading (I): introduction to ThreadLocal and underlying principles
2021 Li Hongyi machine learning (1): basic concepts
【LeetCode】98. Verify the binary search tree (2 brushes of wrong questions)
Utilisation simple de devtools
Sqoop安装