We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💬 문제
[코딩테스트 연습 - 모의고사](https://school.programmers.co.kr/learn/courses/30/lessons/42840)
💬 Idea
💬 풀이
import Foundation func solution(answers:[Int]) -> [Int] { let supoza1 = Array(String(repeating: "12345", count: (answers.count / 5) + 1)).map({ String($0) }) let supoza2 = Array(String(repeating: "21232425", count: (answers.count / 8) + 1)).map({ String($0) }) let supoza3 = Array(String(repeating: "3311224455", count: (answers.count / 10) + 1)).map({ String($0) }) var dict: [Int: Int] = [1: 0, 2: 0, 3: 0] for (index, answer) in answers.enumerated() { dict[1] = supoza1[index] == String(answer) ? dict[1]! + 1 : dict[1] dict[2] = supoza2[index] == String(answer) ? dict[2]! + 1 : dict[2] dict[3] = supoza3[index] == String(answer) ? dict[3]! + 1 : dict[3] } return dict.filter({ $0.value == dict.values.max() }).keys.sorted() }
💬 더 나은 풀이
import Foundation func solution(answers:[Int]) -> [Int] { let supoza1 = [1, 2, 3, 4, 5] let supoza2 = [2, 1, 2, 3, 2, 4, 2, 5] let supoza3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] var dict: [Int: Int] = [1: 0, 2: 0, 3: 0] for (index, answer) in answers.enumerated() { dict[1] = supoza1[index % 5] == answer ? dict[1]! + 1 : dict[1] dict[2] = supoza2[index % 8] == answer ? dict[2]! + 1 : dict[2] dict[3] = supoza3[index % 10] == answer ? dict[3]! + 1 : dict[3] } return dict.filter({ $0.value == dict.values.max() }).keys.sorted() }
The text was updated successfully, but these errors were encountered:
#57 - 모의고사 문제 풀이
7d4c54f
d6e2e16
#57 - 모의고사 문제 풀이 수정
937c44c
hwangJi-dev
No branches or pull requests
💬 문제
[코딩테스트 연습 - 모의고사](https://school.programmers.co.kr/learn/courses/30/lessons/42840)
💬 Idea
💬 풀이
💬 더 나은 풀이
The text was updated successfully, but these errors were encountered: