3. Find the longest substring without repeating characters Given a string, find the length of the longest substring without repeating characters. 给一个字符串,求出最长的无重复字符的子字符串长度。 Examples: Given"abcabcbb", the answeris"abc", which the lengthis3. Given"bbbbb", the answeris"...
0374-guess-number-higher-or-lower.py 0377-combination-sum-iv.py 0392-is-subsequence.py 0394-decode-string.py 0410-split-array-largest-sum.py 0416-partition-equal-subset-sum.py 0417-pacific-atlantic-water-flow.py 0424-longest-repeating-character-replacement.py 0435-non-ov...
438. Find All Anagrams in a String # 题目 # Given a string s and a non-empty string p, find all the start indices of p’s anagrams in s. Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 2
1classSolution {2func numKLenSubstrNoRepeats(_ S: String, _ K: Int) ->Int {3varans:Int =04let n:Int =S.count5let S:[Int] = Array(S).map{$0.ascii}6foriin0..<n7{8varfreq:[Int] = [Int](repeating:0,count:26)9varj:Int =i10varlen:Int =011while(j <n)12{13//a:9714if...
0024-Swap-Nodes-in-Pairs 0025-Reverse-Nodes-In-K-Group 0026-Remove-Duplicates-from-Sorted-Array/Article 0034-find-first-and-last-position-of-element-in-sorted-array 0035-search-insert-position 0036-valid-sudoku 0042-Trap 0048-Rotate-Image 0053 - I. Find number in sort arrayI ...
Btw, If you don't know how to sort a Map on values, see this tutorial first. It will teach youhow to sort HashMap on values in Java. Now getting key and value sorted should be easy, but rememberHashMapdoesn't maintain order, so you need to use a List to keep the entry in sort...
448. Find All Numbers Disappeared in an Array # 题目 # Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find all the elements of [1, n] inclusive that do not appear in this array. C
代码是js写的,如下: 1varlengthOfLongestSubstring =function(str) {2if(str.length === 0)return0;3varmaxLen = 1; //maximum serial string length4varmaxIdx = 0; //the array sub-index of the last char in the result string5vartmpArr = [0]; //array to save the status data6for(vari ...
3. For each different parity state, we save its earliest occurence in a map. For each state, if it has never appeared before, save it to the map. If it has appeared before, update the global best result. A repeating state means the substring in between its earliest and current occurence...
0374-guess-number-higher-or-lower.rs 0392-is-subsequence.rs 0394-decode-string.rs 0402-remove-k-digits.rs 0417-pacific-atlantic-water-flow.rs 0424-longest-repeating-character-replacement.rs 0448-find-all-numbers-disappeared-in-an-array.rs 0450-delete-node-in-a-bst.rs 0456-132-pattern.rs 047...