12345678910111213141516171819202122232425262728let input = Int(readLine()!)!var inputs = [String]()for _ in 1...input{ inputs.append(readLine()!)}for input in inputs{ var stack = [Character]() for i in input{ if(i == "("){ stack.append("(") } else { if let paren = stack.last { if(paren == "("){ stack.removeLast() } else { stack.append(")") } } else { stack.append(")") } } } if(stack.isEmpty){ pr..
123456789101112131415161718192021222324252627282930313233343536373839import Foundation let input = Int(readLine()!)!var stack = [Int]()var commands = [String]()for _ in 1...input{ commands.append(readLine()!)}for command in commands{ if(command.contains("push")){ let number = Int((command.split(separator: " ").last?.description)!)! stack.append(number) } else { switch(command){ case "pop": if le..
1234567891011121314151617181920212223242526272829let input = readLine()!var array = [Int]()var cards = [0,0,0,0,0,0,0,0,0,0]for i in input{ array.append(Int(i.description)!)}for number in array{ cards[number] += 1}var cardsExceptSixAndNine = [Int]()for i in 0..= six+nine){ print(max)} else{ let sub = six+nine-max*2 let more = Int((Double(sub) / 2.0).rounded()) print(max + more)} Colored by Color..
12345678910111213141516171819202122let input = readLine()!.lowercased()var dic = [Character: Int]()for char in input{ if(dic[char] == nil){ dic[char] = 1 } else { dic[char]! += 1 }}//print(dic)let max = dic.values.max()!if(dic.filter({ (content) -> Bool in return content.value == max}).count != 1){ print("?")}else{ let index = (dic.values.index(of: max))! let alphabet = dic.keys[index] print(alp..
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859import Foundation let arrayCount = Int(readLine()!)!var array = [Int]()for _ in 1...arrayCount{ array.append(Int(readLine()!)!)}array = array.sorted(by: Bool in return value == max}let mode: Intif(sortedDic.count == 1){ mode = (sortedDic.first?.key)!} else { sortedDic = sortedDic.sorted(b..
12345678910let input = readLine()!var array = [Int]()for i in input { array.append(Int(i.description)!)}array = array.sorted(by: >)for i in array{ print(i, terminator: "")} Colored by Color Scriptercs 입력받은 문자열의 요소를 순회하면서 정수형으로 캐스팅한 값을 별도의 배열에 저장하고 그 배열을 내림차순 정렬하여 출력한다.