1
class Solution {
2
public:
3
bool isValidSerialization(string preorder) {
4
stringstream s(preorder);
5
string str;
6
int slots = 1;
7
while (getline(s, str, ',')) {
8
if (slots == 0) return 0;
9
if (str == "#")
10
slots--;
11
else
12
slots++;
13
}
14
return slots == 0;
15
}
16
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0