[c++] ํ๋ก๊ทธ๋๋จธ์ค - ํฌ๋ ์ธ ์ธํ๋ฝ๊ธฐ ๊ฒ์(Level 1)
๋ฌธ์ ์ฝ๋ฉํ
์คํธ ์ฐ์ต - ํฌ๋ ์ธ ์ธํ๋ฝ๊ธฐ ๊ฒ์ [[0,0,0,0,0],[0,0,1,0,3],[0,2,5,0,1],[4,2,4,4,2],[3,5,1,3,1]] [1,5,3,5,1,2,1,4] 4 programmers.co.kr ์ฝ๋ #include #include #include using namespace std; int solution(vector board, vector moves) { int answer = 0; stack basket; for(int move:moves){ int pick_num = 0; for(int i=0; i0&&!basket.empty()){ if(basket.top()==pick_num){ basket.pop(); answer+=2; } else basket.push(pi..
2022. 4. 10.
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ํคํจ๋ ๋๋ฅด๊ธฐ(Level 1)
๋ฌธ์ ์ฝ๋ฉํ
์คํธ ์ฐ์ต - ํคํจ๋ ๋๋ฅด๊ธฐ [1, 3, 4, 5, 8, 2, 1, 4, 5, 9, 5] "right" "LRLLLRLLRRL" [7, 0, 8, 2, 8, 3, 1, 5, 7, 6, 2] "left" "LRLLRRLLLRR" [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] "right" "LLRLLRLLRL" programmers.co.kr ์ฝ๋ #include #include using namespace std; string solution(vector numbers, string hand) { string answer = ""; int x_L = 3, y_L = 0; int x_R = 3, y_R = 2; for(int number:numbers){ if(number==1||num..
2022. 4. 10.
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ํ๋ ฌ ํ
๋๋ฆฌ ํ์ ํ๊ธฐ(Level 2)
๋ฌธ์ ์ฝ๋ฉํ
์คํธ ์ฐ์ต - ํ๋ ฌ ํ
๋๋ฆฌ ํ์ ํ๊ธฐ 6 6 [[2,2,5,4],[3,3,6,6],[5,1,6,3]] [8, 10, 25] 3 3 [[1,1,2,2],[1,2,2,3],[2,1,3,2],[2,2,3,3]] [1, 1, 5, 3] programmers.co.kr ์ฝ๋ #include #include using namespace std; vector solution(int rows, int columns, vector queries) { vector answer; vectorv[10001]; int num = 1; for(int i=0; i
2022. 4. 8.