-
Size: a a a
-
M
fn valid_braces(s: &str) -> bool {
let mut stack = vec![];
for c in s.chars() {
match c {
'{'|'('|'[' => stack.push(c),
'}' => {
if let Some(x) = stack.pop() {
if x != '{' { return false }
} else { return false }
},
')' => {
if let Some(x) = stack.pop() {
if x != '(' { return false }
} else { return false }
},
']' => {
if let Some(x) = stack.pop() {
if x != '[' { return false }
} else { return false }
}
_ => (),
}
}
stack.is_empty()
}
Чел с ником Сунь Хуй Вчай:fn valid_braces(s: &str) -> bool {
let mut stack = vec![];
for c in s.chars() {
match c {
'(' => stack.push(')'),
'{' => stack.push(')'),
'[' => stack.push(')'),
x => if Some(x) != stack.pop() { return false }
}
}
stack.is_empty()
}
𝐦
К
M
ED
ED
СВ
СВ
СВ
СВ
СВ
DI
ED
DI
ED
ED
M
M
M