Fix the Parentheses
A parentheses string is valid when every opening ( has a matching closing ) in the correct order. Given a string s containing only parentheses, find the minimum number of parentheses you need to add to make it valid. Return that minimum number.
Примеры
Ввод
"())"Вывод
1Ввод
"((("Вывод
3Ввод
"()"Вывод
0Нужно реализовать
def min_add_to_make_valid(s: str) -> int:
Теги
stringsstack
Log in om je inzendingsgeschiedenis te zien
InloggenLog in om de AI-mentor te gebruiken
InloggenVisible tests
1
Input
"())"Expected
12
Input
"((("Expected
33
Input
"()"Expected
04
Input
"()))(("Expected
45
Input
""Expected
06
Input
")("Expected
2Focus radio
Paused · SomaFM · Fluid