2문제 풀었음
This commit is contained in:
SEAN-59 2025-10-17 00:17:22 +09:00
parent 142d979bc8
commit 03269a0ad3
5 changed files with 84 additions and 11 deletions

View File

@ -2,15 +2,15 @@
[프로그래머스 코딩테스트 고득점 Kit](https://school.programmers.co.kr/learn/challenges?tab=algorithm_practice_kit). [프로그래머스 코딩테스트 고득점 Kit](https://school.programmers.co.kr/learn/challenges?tab=algorithm_practice_kit).
1. 해시 (5문항) 1. 해시 (5문항) S: 2 / P: 5
2. 스택 / 큐 (6문항) 2. 스택 / 큐 (6문항) S: 4 / P: 6
3. 힙 (3문항) 3. 힙 (3문항) S: / P:
4. 정렬 (3문항) 4. 정렬 (3문항) S: / P:
5. 완전탐색 (7문항) 5. 완전탐색 (7문항) S: / P:
6. Greeedy (6문항) 6. Greeedy (6문항) S: / P:
7. DP (5문항) 7. DP (5문항) S: / P:
8. DFS / BFS (7문항) 8. DFS / BFS (7문항) S: / P:
9. B-Search (2문항) 9. B-Search (2문항) S: / P:
10. Graph (3문항) 10. Graph (3문항) S: / P:
- 각각 Swift와 Python으로 풀어볼 것이며 Swift로 먼저 풀이를 진행한다. - 각각 Swift와 Python으로 풀어볼 것이며 Swift로 먼저 풀이를 진행한다.

View File

@ -0,0 +1,21 @@
//
// Clothes.swift
// Test_Coding_Swift
//
// Created by Sean Kim on 10/16/25.
//
import Foundation
///
///
/// [ , ]
///
func clothesSolution(_ clothes:[[String]]) -> Int {
var clothesDict: [String: Int] = [:]
for cloth in clothes {clothesDict[cloth[1], default: 0] += 1}
let combination = clothesDict.values.reduce(1) {$0 * ($1 + 1)}
return combination - 1
}

View File

@ -0,0 +1,6 @@
# Hash?
- Hash 는 Key를 사용하여 해시함수를 통해 해시를 하고 그 결과 값인 주소 값에 해당하는 테이블 슬롯에 value를 저장하는 것이다.
- 해시 테이블은 배열로 이루어져 있다. (딕셔너리의 경우 값이 없으면 nil 리턴이니 이 부분으로 초기화도 잊지 말것)
- 해시 함수는 뭐 따로 있겠지만 해시 함수를 따로 사용하는 것도 좋음
- 해시 테이블 저장을 위해서는 k-v 쌍을 받아야 하고 이를 해시 테이블에 저장만 하면 된다.

View File

@ -0,0 +1,41 @@
//
// FuncDev.swift
// Test_Coding_Swift
//
// Created by Sean Kim on 10/16/25.
//
import Foundation
///
/// , . but
///
func solution(_ progresses:[Int], _ speeds:[Int]) -> [Int] {
var speedCheck = [Int]()
var resultCount = [Int]()
var count = 0
var checkNum = -1
for i in 0 ..< progresses.count {
var checkNum = 100 - progresses[i]
var processDay = checkNum / speeds[i] + (checkNum % speeds[i] > 0 ? 1 : 0)
speedCheck.append(processDay)
}
speedCheck.forEach {speed in
if checkNum == -1 {
checkNum = speed
count += 1
} else if checkNum >= speed {
count += 1
}
if checkNum < speed {
resultCount.append(count)
count = 1
checkNum = speed
}
}
resultCount.append(count)
return resultCount
}

View File

@ -7,5 +7,10 @@
import Foundation import Foundation
print("Hello, World!")
var result = solution([93, 30, 55],[1, 30, 5])
//var result = solution([95, 90, 99, 99, 80, 99],[1, 1, 1, 1, 1, 1])
//var result = solution([94,95,90],[4,3,1])
print(result)