본문 바로가기

HOME

(207)
[프로그래머스/C++] K번째수 #include #include #include using namespace std; vector solution(vector array, vector commands) { vector answer; vector temp; int size = commands.size(); int te1, te2, te3; for (int i = 0; i < size; ++i) { te1 = commands[i][0] -1; te2 = commands[i][1]; te3 = commands[i][2] -1; answer.assign(array.begin() + te1, array.begin() + te2); sort(answer.begin(), answer.end()); temp.push_back(answer[te3]);..
[프로그래머스/C++] 2016년 #include #include using namespace std; string solution(int a, int b) { string answer = ""; int c = 0; --a; if(a != 0) { if(a == 1) { b+= 31; }else if((a % 2 == 1 && a 7)) { a /= 2; c = a + 1; if(a >= 4) { --a;} b += c * 31 + a * 30 - 1; } else { a /= 2; c = a; if(c >= 4) ++c; b += c * 31 + a * 30 - 1; } } b = b % 7; switch (b) { case 1: answer = "FRI";break; case 2: an..
크레인 인형뽑기 #include #include using namespace std; int solution(vector board, vector moves) { vector ans; int answer = 0; int mv =0; int j=0; int k = 0; for (int i = 0; i
단어 공부 #include using namespace std; int main() { string str; cin >> str; vector arr('Z'+1); for(int i = 0; i
Determine if String Halves Are Alike class Solution { public: bool halvesAreAlike(string s) { string a = s.substr(0, s.length()/2); string b = s.substr(s.length()/2, s.length()); int acnt = 0, bcnt = 0; for(int i = 0; i
Valid Perfect Square class Solution { public: bool isPerfectSquare(int num) { return ceil(sqrt(num)) == floor(sqrt(num)) ? true : false; } };
Sqrt(x) class Solution { public: int mySqrt(int x) { return floor(sqrt(x)); } };
Self Dividing Numbers class Solution { public: vector selfDividingNumbers(int left, int right) { vector answer; int temp = 0, div = 0; for(int i = left; i