We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a46e6e6 commit d443cd1Copy full SHA for d443cd1
1 file changed
live9/test99/문제3/황장현.js
@@ -0,0 +1,28 @@
1
+function solution(s) {
2
+ const obj = {
3
+ '}': '{',
4
+ ']': '[',
5
+ ')': '(',
6
+ };
7
+
8
+ const isCorrect = (string) => {
9
+ const stack = [];
10
+ for (const char of string) {
11
+ if ('{[('.includes(char)) stack.push(char);
12
+ else if (obj[char] !== stack.pop()) return false;
13
+ }
14
+ return stack.length ? false : true;
15
16
17
+ const rotate = (string) => string.substringing(1) + string[0];
18
19
+ let result = 0;
20
+ for (let i = 0; i < s.length; i++) {
21
+ s = rotate(s);
22
23
+ result += isCorrect(s) ? 1 : 0;
24
25
+ return result;
26
+}
27
28
+console.log(solution('[](){}'));
0 commit comments