#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;
}
#include <string>
#include <vector>
#include <iostream>
using namespace std;

string solution(int a, int b) {
    string answer = "";
    int value = 0;
    vector<int>month{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    vector<string>date {"FRI", "SAT","SUN", "MON", "TUE", "WED", "THU"};
    for(int i=0; i <a-1; i++){
        value = (value + month[i]% 7) % 7;
    }
    value =(value+ b % 7 -1)%7;

    answer = date[value];
    return answer;
}
#include<string>
#include <stack>
#include <iostream>

using namespace std;

bool solution(string s)
{
    bool answer = true;
    stack <char> st;
    if(s[0] == '('){
        //st.push(s[0]);
        for(int i =0; i < s.length(); i++){
            char ss = s[i];
            if(ss == '(')
                st.push(ss);
            else{
                if(!st.empty())
                    st.pop();
                else{
                    answer = false;
                    break;
                }
            }
            if(st.empty())
                answer = true;
            else
                answer = false;
         }
    }
    else
        answer = false;
    
    return answer;
}

'자윤이와고리즘 > Code' 카테고리의 다른 글

[프로그래머스] 모의고사  (0) 2019.07.22
[프로그래머스] 폰켓몬  (0) 2019.07.22
[프로그래머스] 카펫  (0) 2019.07.22
[프로그래머스] 전화번호 목록  (0) 2019.07.22
[프로그래머스] 큰 수 만들기  (0) 2019.07.22

+ Recent posts