-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c80765
commit 3febd99
Showing
4 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+2.76 KB
(110%)
...odeproj/project.xcworkspace/xcuserdata/hwangji.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// 크레인 인형뽑기 게임.swift | ||
// ProgrammersLevel1 | ||
// | ||
// Created by hwangJi on 2022/08/02. | ||
// | ||
|
||
import Foundation | ||
|
||
func solution(_ board:[[Int]], _ moves:[Int]) -> Int { | ||
var gameBoard: [[Int]] = board | ||
var stack: [Int] = [] | ||
var count: Int = 0 | ||
|
||
for i in moves { | ||
for j in 0..<gameBoard.count { | ||
if gameBoard[j][i - 1] != 0 { | ||
if stack.last == gameBoard[j][i - 1] { | ||
stack.removeLast() | ||
count += 1 | ||
} else { | ||
stack.append(gameBoard[j][i - 1]) | ||
} | ||
gameBoard[j][i - 1] = 0 | ||
break | ||
} | ||
} | ||
} | ||
|
||
return count * 2 | ||
} |
Binary file modified
BIN
-18 Bytes
(100%)
...odeproj/project.xcworkspace/xcuserdata/hwangji.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.