当前位置:网站首页>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;
}边栏推荐
- LeetCode146. LRU cache
- Avoid material "minefields"! Play with super high conversion rate
- 有个疑问 flink sql cdc 的话可以设置并行度么, 并行度大于1会有顺序问题吧?
- Azkaban actual combat
- Pat class a 1162 postfix expression
- Marubeni Baidu applet detailed configuration tutorial, approved.
- Flume配置4——自定义MYSQLSource
- February database ranking: how long can Oracle remain the first?
- PHP cli getting input from user and then dumping into variable possible?
- [Yu Yue education] National Open University spring 2019 0505-22t basic nursing reference questions
猜你喜欢

The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety

Sqoop command

Utilisation simple de devtools

Apache build web host

【LeetCode】222. The number of nodes of a complete binary tree (2 mistakes)

Qrcode: generate QR code from text

Bumblebee: build, deliver, and run ebpf programs smoothly like silk

openresty ngx_lua執行階段

Apache Web page security optimization

Devtools的簡單使用
随机推荐
d3js小记
Bumblebee: build, deliver, and run ebpf programs smoothly like silk
Android advanced interview question record in 2022
Design and implementation of community hospital information system
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
[Yu Yue education] National Open University spring 2019 0505-22t basic nursing reference questions
Azkaban概述
LeetCode146. LRU cache
Bumblebee: build, deliver, and run ebpf programs smoothly like silk
Zabbix
Tencent cloud, realize image upload
Simple use of devtools
Last words record
单项框 复选框
为什么腾讯阿里等互联网大厂诞生的好产品越来越少?
【LeetCode】98. Verify the binary search tree (2 brushes of wrong questions)
Summary and practice of knowledge map construction technology
Port, domain name, protocol.
Asp+access campus network goods trading platform
Returns the lowest common ancestor of two nodes in a binary tree