๋ฌธ์
์ฝ๋
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> arr) {
vector<int> answer;
int min_index = min_element(arr.begin(),arr.end())-arr.begin();
if(arr.size()==1) answer.push_back(-1);
else{
arr.erase(arr.begin()+min_index);
answer=arr;
}
return answer;
}
ํ์ด
์ด ๋ฌธ์ ๋ 7 1 6 9 ๋ผ๋ ๊ฐ์ด ์์ ๋ ๋น ๋ด๋ฆผ์ฐจ์์ธ 9 7 6 ์ด ์๋ 7 6 9 ์ผ๋ก ์ถ๋ ฅ์ ํด์ผ ํฉ๋๋ค.
'Algorithm ๐ง๐ปโ๐ป > ํ๋ก๊ทธ๋๋จธ์ค(Programmers)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ํผ๋ณด๋์น ์( Level2) (0) | 2021.11.08 |
---|---|
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์ต๋๊ณต์ฝ์์ ์ต์๊ณต๋ฐฐ์( Level1) (0) | 2021.11.08 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ๋ฐฐ๋ฌ( Level2) (0) | 2021.11.08 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์๋ฐ์๋ฐ์๋ฐ์๋ฐ์๋ฐ์?( Level1) (0) | 2021.11.08 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ๋ฐฉ๋ฌธ ๊ธธ์ด( Level 2) (0) | 2021.11.08 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ์๋ ์ซ์ ๋ํ๊ธฐ( Level 1) (0) | 2021.11.07 |
๋๊ธ