Notice
Recent Posts
Recent Comments
- Today
- Total
01-11 08:45
Tags
- tree
- OOP
- array
- spring
- MST
- ์์์ ๋ ฌ
- BFS
- PS
- Graph
- ๋ฐฑ์ค
- Algorithm
- database
- ํ๋ก๊ทธ๋๋จธ์ค
- ๊ทธ๋ฆฌ๋
- java
- ๋ฐฑ์๋
- ๋ฐ์ดํฐ๋ฒ ์ด์ค
- ์กธ์ ์ํ
- dp
- ๋ฌธ๋ฒ
- leetcode
- ์๋ฐ
- ์ธํด
- ๊ตฌํ
- ์๋ฐ์์ ์
- CS
- ์๋ฃ๊ตฌ์กฐ
- ๋ฒจ๋งํฌ๋
- ๋ค์ต์คํธ๋ผ
- pytorch
Link
Partially Committed
[์ ๋ ฌ] k๋ฒ์งธ์ ๋ณธ๋ฌธ
728x90
๋ฐ์ํ
SMALL
https://programmers.co.kr/learn/courses/30/lessons/42748
vector ์ assign ์ ์ด์ฉํ์ฌ temp vector ์ slice ํ ๋ค์ sorting ํ์ฌ ์๊ตฌํ๋ ์์น์ ๊ฐ์ answer ๋ฐฐ์ด์ insert ํ๋ค.
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
vector<int> solution(vector<int> array, vector<vector<int>> commands) {
vector<int> answer;
int n = commands.size();
for (int i = 0; i < n; i++)
{
vector<int> temp;
temp.assign(array.begin() + commands[i][0] - 1, array.begin() + commands[i][1]);
sort(temp.begin(), temp.end());
answer.insert(answer.begin() + i, temp[commands[i][2] - 1]);
}
return answer;
}
728x90
๋ฐ์ํ
LIST
'๐ฅ Algorithm || ๋ฌธ์ ํ์ด > PS' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ชจ์๊ณ ์ฌ (0) | 2022.07.02 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ์์ฃผํ์ง ๋ชปํ ์ ์ (0) | 2022.07.02 |
[Summer/Winter Coding(~2018)] ์์ ๋ง๋ค๊ธฐ (0) | 2022.07.01 |
[์๊ฐ ์ฝ๋ ์ฑ๋ฆฐ์ง ์์ฆ1] ๋ด์ (0) | 2022.07.01 |
[์๊ฐ ์ฝ๋ ์ฑ๋ฆฐ์ง ์์ฆ2] ์์ ๋ํ๊ธฐ (0) | 2022.07.01 |
Comments