当前位置:网站首页>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;
}
边栏推荐
- Can you really learn 3DMAX modeling by self-study?
- openresty ngx_lua执行阶段
- LeetCode --- 1071. Great common divisor of strings problem solving Report
- Bumblebee: build, deliver, and run ebpf programs smoothly like silk
- Yuan universe also "real estate"? Multiple second-hand trading websites block metauniverse keywords
- Start the remedial work. Print the contents of the array using the pointer
- Structure of ViewModel
- d3js小记
- Design of kindergarten real-time monitoring and control system
- Scientific research: are women better than men?
猜你喜欢
Simple use of devtools
2. Common request methods
Can you really learn 3DMAX modeling by self-study?
2021 Li Hongyi machine learning (1): basic concepts
丸子百度小程序详细配置教程,审核通过。
Bumblebee: build, deliver, and run ebpf programs smoothly like silk
Acwing第 58 场周赛【完结】
Pat grade a 1119 pre- and post order traversals (30 points)
This + closure + scope interview question
Summary and practice of knowledge map construction technology
随机推荐
Day_ 17 IO stream file class
Pytest (4) - test case execution sequence
Learn game model 3D characters, come out to find a job?
Yuan universe also "real estate"? Multiple second-hand trading websites block metauniverse keywords
Utilisation simple de devtools
Avoid material "minefields"! Play with super high conversion rate
Blue bridge - maximum common divisor and minimum common multiple
Elk log analysis system
D3js notes
Devtools的簡單使用
Leetcode takes out the least number of magic beans
ELFK部署
Sqoop command
Design and practice of kubernetes cluster and application monitoring scheme
Structure of ViewModel
IPv6 experiment
PHP cli getting input from user and then dumping into variable possible?
GFS distributed file system
Character painting, I use characters to draw a Bing Dwen Dwen
使用druid連接MySQL數據庫報類型錯誤