Skip to content

Commit

Permalink
Merge pull request #79 from AlgoLeadMe/23-alstjr7437
Browse files Browse the repository at this point in the history
23-alstjr7437
  • Loading branch information
tgyuuAn authored May 10, 2024
2 parents a13af6f + cd17ca4 commit 5302e78
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ for i in 1...n{
}
}

print(result)
print(result)
5 changes: 3 additions & 2 deletions alstjr7437/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
| 17์ฐจ์‹œ | 2024.03.16 | DP | <a href="https://www.acmicpc.net/problem/2228">๊ตฌ๊ฐ„ ๋‚˜๋ˆ„๊ธฐ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/61 |
| 18์ฐจ์‹œ | 2024.03.23 | ๋‹ค์ต์ŠคํŠธ๋ผ | <a href="https://www.acmicpc.net/problem/1753">์ตœ๋‹จ ๊ฒฝ๋กœ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/66 |
| 19์ฐจ์‹œ | 2024.03.27 | ๋ฌธ์ž์—ด | <a href="https://www.acmicpc.net/problem/5525">IOIOI</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/67 |
| 20์ฐจ์‹œ | 2024.04.03 | BFS | <a href="https://www.acmicpc.net/problem/1697">์ˆจ๋ฐ”๊ผญ์งˆ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/70 |
| 22์ฐจ์‹œ | 2024.04.13 | BFS | <a href="https://www.acmicpc.net/problem/11724">์—ฐ๊ฒฐ ์š”์†Œ์˜ ๊ฐœ์ˆ˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/78 |
| 21์ฐจ์‹œ | 2024.04.06 | ๋น„ํŠธ๋งˆ์Šคํ‚น | <a href="https://www.acmicpc.net/problem/11723">์ง‘ํ•ฉ</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/74 |
| 22์ฐจ์‹œ | 2024.04.13 | BFS | <a href="https://www.acmicpc.net/problem/11724">์—ฐ๊ฒฐ ์š”์†Œ์˜ ๊ฐœ์ˆ˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/78 |
| 22์ฐจ์‹œ | 2024.04.13 | BFS | <a href="https://www.acmicpc.net/problem/11724">์—ฐ๊ฒฐ ์š”์†Œ์˜ ๊ฐœ์ˆ˜</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/78 |
| 23์ฐจ์‹œ | 2024.05.01 | ํ | <a href="https://school.programmers.co.kr/learn/courses/30/lessons/42587">ํ”„๋กœ์„ธ์Šค</a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/79 |
29 changes: 29 additions & 0 deletions alstjr7437/ํ/ํ”„๋กœ์„ธ์Šค.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import Foundation

func solution(_ priorities:[Int], _ location:Int) -> Int {
var result = 0
var priorities = priorities
var location = location

while priorities.count != 0 {
location -= 1
let p_max = priorities.max()!
let temp = priorities[0]
if p_max != temp { // max๊ฐ€ ์•„๋‹ ๊ฒฝ์šฐ(๋นผ์•ผํ•  ๊ฒฝ์šฐ๊ฐ€ ์•„๋‹Œ ๊ฒฝ์šฐ)
priorities.append(temp) // ๋’ค์— ๋„ฃ๊ธฐ
priorities.removeFirst() // ์ฒ˜์Œ๊บผ ๋นผ๊ธฐ
if location < 0 { // location์ด ์Œ์ˆ˜๋ฉด ์ œ์ผ ๋’ค์—์„œ ๋ถ€ํ„ฐ
location = priorities.count - 1
}
} else { // max์ผ ๊ฒฝ์šฐ(๋นผ์•ผํ•  ๊ฒฝ์šฐ)
priorities.removeFirst()
result += 1
if location < 0 { // location์ด ์ ์ ˆํ•˜๊ฒŒ ์˜ค๋ฉด ๋ฉˆ์ถ”๊ธฐ
break
}
}

}

return result
}

0 comments on commit 5302e78

Please sign in to comment.