Actieve werkgever
Given a string, return a boolean value if the strings contains matching brackets Example: Input: "This is [a valid] string" Output: True Input: "This is an [invalid string" Output: False
Anoniem
Use a stack data structure
function fun(){ $st = "This is [[a valid] st]ring"; $a = str_split($st); $brack_opens = array_keys($a,"["); $brack_close = array_keys($a,"]"); if(count($brack_opens)==count($brack_close)) return "true"; return "false"; } print(fun());
That doesn't work. It would return valid for a string like this "This is ]]a valid[ st[ring"
Volg de bedrijven van je dromen om als eerste op de hoogte te zijn van vacatures en te profiteren van tips van insiders.
Zoek naar vacatures om gepersonaliseerde vacature-aanbevelingen en -updates te krijgen.