2458. ?? ?? ?? ?? ? ?? ?? ??
???:???
??: ??, ??, ?? ?? ??, ?? ?? ??, ?? ??
n?? ??? ?? ?? ??? ??? ?????. ? ???? 1?? n?? ??? ?? ?????. ?? m ??? ?? ??? ?????.
i?? ???? ??? ???? ???? m ?? ??? ???? ???.
- ???? query[i] ?? ?? ??? ??? ?? ?? ??? ?????. ??[i]? ?? ?? ?? ?????.
??? m? ?? ??? ?????. ??? ??[i]? i?? ??? ??? ? ??? ?????.
??:
- ??? ?????? ? ?? ?? ??? ?? ??? ?????.
- ??? ??? ???? ??? ?? ????? ?? ? ?? ??? ?? ???? ????.
? 1:
- ??: ?? = [1,3,4,2,null,6,5,null,null,null,null,null,7], ?? = [4]
- ??: [2]
-
??: ? ?????? ?? 4? ??? ??? ?? ?? ??? ??? ?? ??? ?????.
- ??? ??? 2???(?? 1 -> 3 -> 2).
? 2:
- ??: ?? = [5,8,9,2,1,3,7,4,6], ?? = [3,2,4,8]
- ??: [3,2,3,2]
-
??: ??? ?? ??? ????.
- ?? 3? ??? ??? ?? ?? ??? ?????. ??? ??? 3? ???(?? 5 -> 8 -> 2 -> 4).
- ?? 2? ??? ??? ?? ?? ??? ?????. ??? ??? 2? ???(?? 5 -> 8 -> 1).
- ?? 4? ??? ??? ?? ?? ??? ?????. ??? ??? 3? ???(?? 5 -> 8 -> 2 -> 6).
- ?? 8? ??? ??? ?? ?? ??? ???? ??? ??? 2? ???(?? 5 -> 9 -> 3).
????:
- ??? ?? ?? n????.
- 2 5
- 1 <= Node.val <= n
- ??? ?? ?? ?????.
- m == ?? ??
- 1 4)
- 1 <= ??[i] <= n
- ??[i] != root.val
??:
- 1?? n?? ? ??? ?? ?? ?? ???? ? ??? O(1)? ?? ???.
- ? ?? ??? ??? ??? ? ?? ?? ???? ??? ?? ??? ? ????.
???:
? ???? 2?? ?? ??? ?????.
- ???? ? ??? ??? ?????.
- ??? ? ??? ??? ?? ?? ??? ??? ? ??? ?? ??? ?????.
PHP?? ? ???? ??? ?????: 2458. ?? ?? ?? ?? ? ?? ?? ??
?? ??
1. ??? ?? ? ??:
class Solution { private $valToMaxHeight = []; private $valToHeight = [];
- valToMaxHeight: ? ??? ? ??? ?? ??? ??? ? ??? ?? ??? ?????.
- valToHeight: ? ??? ? ??? ?? ?? ??? ?????.
2. ?? ??:
function treeQueries($root, $queries) { ... ... ... /** * go to ./solution.php */ }
- treeQueries ??? ??? ??? ?? ??? ?????.
- ?? ?? ??? ???? ? ??? ??? ?????.
- ?? ?? dfs(?? ?? ??) ??? ???? ?? ?? ?? ? ?? ??? ?????.
- ????? ? ??? ??? ?? ??? ????.
3. ?? ??:
private function height($node) { ... ... ... /** * go to ./solution.php */ }
- ? ??? ? ??? ??? ????? ?????.
- ??? null?? 0? ?????.
- ??? ??? ?? ??? ?? ??(valToHeight)?? ?? ?????.
- ??? ??? ??? ?? ???? ?? ???? valToHeight? ?????.
4. ?? ??? ?? ?? ?? ??:
private function dfs($node, $depth, $maxHeight) { ... ... ... /** * go to ./solution.php */ }
- ? ??? DFS? ???? ? ??? ?? ??? ??? ? ??? ?? ??? ?????.
- ?? ??? ?? ?? ??? valToMaxHeight? ?????.
- ?? ? ??? ?? ??? ??? ???? ?? ?? ?? ??? ???????.
- ??? ??? ??? ?? ??? ????? ???? ??? ?? ??? ???????.
?? ??
??? ???? ???????.
?? ?:
// Tree Structure // 1 // / \ // 3 4 // / / \ // 2 6 5 // \ // 7 $root = [1, 3, 4, 2, null, 6, 5, null, null, null, null, null, 7]; $queries = [4];
?? ?? ??:
- 1:3?? ??? ?? ??? ??
- ????? ??? 3:2
- 4:2? ??? ? ??? ??(6? 5? ??? ? ?? ??? ??)
- ??? 6:1? ??? ??(?? ?? 7)
- 2:0(?? ??)? ??? ? ??? ??
?? ?? ? valToHeight? ??? ????.
class Solution { private $valToMaxHeight = []; private $valToHeight = [];
Max Heights? DFS:
- ??(1)? ?? ?? ?? 4? ?? ?????.
- ?? ??: 2(??? 3)
- ??? ??: 1(??? 5)
- ??? 4? ??? ?? ?? ??? 2???.
?? ? ?? ??:
- ?? 4? ?? ??? [2]???.
?? ??
??? ??? ??? ??? ????.
function treeQueries($root, $queries) { ... ... ... /** * go to ./solution.php */ }
? ???? ?? ??? ?? ??? ??? ????? ???? ?? ??? ? ??? ?? ?? ? ??? ??? ? ????. ?? ???? O(n·m)???. ??? n? ??? ?? ??? ???. m? ?? ????.
??? ??
? ???? ??? ???? GitHub?? ???? ??? ????? ???? ?? ?????? ???? ??? ???. ???? ??? ??? ? ??? ? ????!
??? ? ??? ???? ???? ?? ???????.
- ????
- ???
? ??? ?? ?? ?? ?? ? ?? ??? ??? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

PHP ?? ??? ?? ???? ?? ? ????? ??? ?????. 1. ?? ??? ??? ??? ??? ? ? ??? ??? ??? ?? ?? ??? ???? ???????. 2. ?? ??? ???? ???? ? ?? ????? ?? ?? ?? ??? ?????. 3. $ _get ? $ _post? ?? Hyperglobal ??? ?? ???? ?? ??? ? ??? ??? ??????? ???????. 4. ?? ?? ?? ???? ?? ?? ?? ??? ?????? ?? ??? ??? ?? ??? ???????. ??? ??? ????? ??? ??? ?? ???? ????? ? ??? ? ? ????.

PHP ?? ???? ???? ????? ?? ? ??? ???? ?? ?? ? ??? ???? ?? ??? ?????? ??? ??? ? ? ???????. 1. ??? ?? CSRF? ???? ?? ??? ??? ???? ?????? ??? ???? FINFO_FILE? ?? ?? MIME ??? ?????. 2. ??? ??? ??? ???? ??? ?? ??? ?? ? WEB ????? ??? ???? ??????. 3. PHP ?? ??? ?? ? ?? ???? NGINX/APACHE? ??? ????? ?? ???? ?????. 4. GD ?????? ??? ? ?? ???? ??? ?? ??? ?? ????.

PHP ?? ???? ? ?? ???? ??? ????. 1. // ?? #? ???? ? ?? ??? ???? // ???? ?? ????. 2. ?? /.../ ?? ?? ?? ??? ????? ?? ? ?? ??? ?? ? ? ????. 3. ?? ?? ?? / if () {} /? ?? ?? ??? ????? ??? ?? ?? ?? ??? ???? ????? ???? ??? ?? ???? ???? ??? ? ??? ??????.

Ageneratorinphpisamemory- ???? Way-Erate-Overgedatasetsetsbaluesoneatimeatimeatimeatimallatonce.1.generatorsuseTheyieldKeywordTocroadtOpvaluesondemand, RetingMemoryUsage.2

PHP ??? ???? ??? ??? ??? ????? ????. ??? ????? ?? ???? ??? "?? ? ?"??? "?"? ???????. 1. ??? ? ??? ??? DocBlock (/*/)? ?? ?? ??? ???? ??? ? ?? ???? ??????. 2. JS ??? ???? ?? ???? ??? ?? ??? ??? ?????. 3. ??? ?? ?? ?? ??? ???? ????? ????? ???? ?? ????? ???? ? ??????. 4. Todo ? Fixme? ????? ???? ? ? ??? ??? ???? ?? ?? ? ??? ???????. ??? ???? ?? ??? ??? ?? ?? ?? ???? ???? ? ????.

PHP??? ???? ??? ?? ?? ????? ???? ??? ?? ??? ??? ?? ? ??? ??? ???? ?????. ???? 0?? ???? ?? ??? ???? ? ?? ???? ?? ?? ? ? ????. MB_SUBSTR? ?? ??? ??? ???????. ? : $ str = "hello"; echo $ str [0]; ?? H; ??? MB_SUBSTR ($ str, 1,1)? ?? ??? ??? ??? ??????. ?? ???????? ???? ??? ???? ?? ???? ?? ?? ???? ?????? ??? ????? ?? ??? ?? ??? ???? ???? ?? ????.

toinstallphpquickly, usexampponwindowsorhomebrewonmacos.1. ??, downloadandinstallxAmpp, selectComponents, startApache ? placefilesinhtdocs.2

tolearnpheffectical, startBysetTupaloCalserErverEnmentUsingToolslikexamppandacodeeditor -likevscode.1) installxamppforapache, mysql, andphp.2) useacodeeditorforsyntaxsupport.3)) 3) testimplephpfile.next, withpluclucincludechlucincluclucludechluclucled
