Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use PHP and Golang to browse leetCode

Shulou Source: shulou.com Published: 2022-06-02 03:21:10 09月18日 Update

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)

Tags: Characters methods strings questions checks more help answers easy longest almost easy between content guys buddies ideas knowledge articles indexes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple vpn OPPO Reno Huawei Shulou Tech Info