공부
2문제 풀었음
This commit is contained in:
parent
142d979bc8
commit
03269a0ad3
20
README.md
20
README.md
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
[프로그래머스 코딩테스트 고득점 Kit](https://school.programmers.co.kr/learn/challenges?tab=algorithm_practice_kit).
|
||||
|
||||
1. 해시 (5문항)
|
||||
2. 스택 / 큐 (6문항)
|
||||
3. 힙 (3문항)
|
||||
4. 정렬 (3문항)
|
||||
5. 완전탐색 (7문항)
|
||||
6. Greeedy (6문항)
|
||||
7. DP (5문항)
|
||||
8. DFS / BFS (7문항)
|
||||
9. B-Search (2문항)
|
||||
10. Graph (3문항)
|
||||
1. 해시 (5문항) S: 2 / P: 5
|
||||
2. 스택 / 큐 (6문항) S: 4 / P: 6
|
||||
3. 힙 (3문항) S: / P:
|
||||
4. 정렬 (3문항) S: / P:
|
||||
5. 완전탐색 (7문항) S: / P:
|
||||
6. Greeedy (6문항) S: / P:
|
||||
7. DP (5문항) S: / P:
|
||||
8. DFS / BFS (7문항) S: / P:
|
||||
9. B-Search (2문항) S: / P:
|
||||
10. Graph (3문항) S: / P:
|
||||
|
||||
- 각각 Swift와 Python으로 풀어볼 것이며 Swift로 먼저 풀이를 진행한다.
|
||||
|
|
|
|||
21
Test_Coding_Swift/Test_Coding_Swift/Hash/Clothes.swift
Normal file
21
Test_Coding_Swift/Test_Coding_Swift/Hash/Clothes.swift
Normal 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
|
||||
}
|
||||
|
||||
|
||||
6
Test_Coding_Swift/Test_Coding_Swift/Hash/Hash.md
Normal file
6
Test_Coding_Swift/Test_Coding_Swift/Hash/Hash.md
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
# Hash?
|
||||
- Hash 는 Key를 사용하여 해시함수를 통해 해시를 하고 그 결과 값인 주소 값에 해당하는 테이블 슬롯에 value를 저장하는 것이다.
|
||||
- 해시 테이블은 배열로 이루어져 있다. (딕셔너리의 경우 값이 없으면 nil 리턴이니 이 부분으로 초기화도 잊지 말것)
|
||||
- 해시 함수는 뭐 따로 있겠지만 해시 함수를 따로 사용하는 것도 좋음
|
||||
- 해시 테이블 저장을 위해서는 k-v 쌍을 받아야 하고 이를 해시 테이블에 저장만 하면 된다.
|
||||
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -7,5 +7,10 @@
|
|||
|
||||
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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user