-
[Swift] ๋ฐฑ์ค 9012 ๊ดํธ (Data Structure)๐ป Algorithm/Swift 2023. 1. 31. 22:45
๐ ํ์ด
๐ฌ Code
import Foundation for _ in 0..<Int(readLine()!)! { var stack = [String]() let input = readLine()!.map { String($0) } input.forEach { char in if char == "(" { stack.append(char) } else if stack.last == "(" && !stack.isEmpty { stack.removeLast() } else { stack.append(char) } } print(stack.isEmpty ? "YES" : "NO") }
'๐ป Algorithm > Swift' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Swift] ๋ฐฑ์ค 2178 ๋ฏธ๋ก ํ์ (Graph Traversal) (0) 2023.01.31 [Swift] ๋ฐฑ์ค 2667 ๋จ์ง๋ฒํธ๋ถ์ด๊ธฐ (Graph Traversal) (0) 2023.01.31 [Swift] ๋ฐฑ์ค 2606 ๋ฐ์ด๋ฌ์ค (Graph Traversal) (0) 2023.01.31 [Swift] ๋ฐฑ์ค 1260 DFS์ BFS (Graph Traversal) (0) 2023.01.31 [Swift] ๋ฐฑ์ค 14490 ๋ฐฑ๋์ด (์ต๋๊ณต์ฝ์ GCM ๋ฌธ์ ) (0) 2023.01.31