ํ์ด ํ๋ผ๋ ๋๋ก ๊ตฌํํ๋ค. ์ด๊ฑฐ ๋ถ์บ ์ํ์์ ๋์จ๊ฒ ๊ฐ์ ๊ธฐ๋ถ์ด.. ์ผ๋จ ๊ทธ๋ฆฌ๊ณ ํ์ด์ฌ๋ณด๋ค ์ค์ํํธ๊ฐ ๋ ํธํ ์ด์ ํ์์ด ๋ฐ๊ฒฌ๋๋คโฆ Code import Foundation func getGrade(_ id: Int, _ scores: [Int]) -> String { // ์ต์ index๋ค ๊ตฌํจ -> ์ผ๋จ ๊ทธ ์์ id๊ฐ ํฌํจ๋์ด ์๋์ง ํ์ธ -> ํฌํจ๋์ด ์๋ค๋ฉด ์์ ๊ฐ์๊ฐ 1๊ฐ์ธ์ง // ์ต๋ index๋ค ๊ตฌํจ var scores = scores let minScore = scores.min()! let maxScore = scores.max()! let minIndices = scores.enumerated().filter({ $0.element == minScore }).map { $0.offset} let maxIndices = scores.enumerated().filter({ $0.element == maxScore }).map { $0.offset} if minIndices.count == 1 && minIndices.contains(id) { // ์ ์ผํ ์ต์ ์ ์ธ ๊ฒฝ์ฐ scores.remove(at: id) } else if maxIndices.count == 1 && maxIndices.contains(id) { // ์ ์ผํ ์ต๊ณ ์ ์ธ ๊ฒฝ์ฐ scores.remove(at: id) } let meanScore = scores.reduce(0, { $0 + $1 })/scores.count switch meanScore { case 90...: return "A" case 80..<90: return "B" case 70..<80: return "C" case 50..<70: return "D" case ..<50: return "F" default: return "" } } func solution(_ scores:[[Int]]) -> String { var studentScore = Dictionary<Int, [Int]>() let numberOfStudents = scores.count for i in 0..<numberOfStudents { studentScore[i] = scores.map { $0[i] } } var answer = "" for i in 0..<numberOfStudents { answer += getGrade(i, studentScore[i]!) } return answer } Reference ์ํธ ํ๊ฐ