How to use PHP and Golang to browse leetCode
How to use PHP and Golang to browse leetCode, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Method one
Class Solution {/ * @ param String $s * @ return Integer * / function lengthOfLongestSubstring ($s) {if (strlen ($s) = = 0) return 0; $map = []; $max = 0; $left = 0; for ($I = 0; $I < strlen ($s) ) {if (array_key_exists ($s [$I], $map)) {$left = max ($left, $map [$s [$I]] + 1);} $map [$s [$I] = $I; $max = max ($max,$i-$left+1);} return $max;}}
Method 2:
Idea: check all the substrings one by one to see if they contain duplicate characters.
$str = ""; function lengthOfLongestSubstring ($s) {$strlen = strlen ($s); if ($strlen)