#include <string>
#include <vector>

using namespace std;

string solution(int n) {
    string answer = "";
    vector <string> watermelon {"수", "박"};
    for(int i=0;i < n; i++){
        answer += watermelon[i%2];
    }
    return answer;
}
#include <string>
#include <vector>

using namespace std;
vector<int> sort(vector<int> a){
    int tmp = 0;
    for(int i=0; i < a.size()-1; i++){
        for(int j  = i+1;j < a.size(); j++){
            if(a[i]>a[j]){
                tmp = a[i];
                a[i] = a[j];
                a[j] = tmp;
            }
        }
    }
    return a;
}
vector<int> solution(vector<int> arr, int divisor) {
    vector<int> answer;
    for(int i=0; i < arr.size(); i++){
        if(arr[i] % divisor == 0 )
            answer.push_back(arr[i]);
    }
    if(answer.size()==0)
        answer.push_back(-1);
    else
        answer = sort(answer);
    return answer;
}
#include <vector>
#include <iostream>

using namespace std;

vector<int> solution(vector<int> arr) 
{
    vector<int> answer;

    int tmp = arr[0];
    answer.push_back(tmp);
    for(int i=1; i < arr.size(); i++){
        if(tmp == arr[i]){
            continue;
        }
        tmp = arr[i];
        answer.push_back(tmp);
    }
    return answer;
}
#include <string>
#include <vector>

using namespace std;

string solution(string s) {
    string answer = "";
    int leng = s.length();

    if(leng%2 ==0){
        for(int i=leng/2-1; i <=leng/2; i++)
            answer += s[i];
    }
    else
        answer = s[leng/2];
    return answer;
}

+ Recent posts