일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- cpp
- 딥러닝
- 캐나다 영주권
- 머신러닝
- 선형대수
- 방송통신대학교
- Deep learning
- EOI
- 코딩테스트
- Plotting
- 매트랩
- 온라인석사
- 기본
- MATLAB
- 개발자
- 위니펙
- omscs
- machine learning
- zeros
- 프로그래머스
- 주정부이민
- LAA
- 알고리즘
- 방통대
- mpnp
- leetcode
- 조지아텍
- LV1
- 컴퓨터과학과
- C++
- Today
- Total
목록cpp (12)
Byte by Byte

핵심 : 진법 변환 연습. 배운 것 : vector를 썼다면, to_string과 y[i]-0을 생략할 수 있었겠다. #include #include #include using namespace std; string convertToTernary(int& x){ string s = ""; while(x!=0){ s += to_string(x % 3); x /= 3; } return s; } int convertToDecimal(string y){ int decimal = 0; for(int i =0; i < y.size(); i++) decimal += (y[i]-'0')*pow(3,y.size()-(i+1)); return decimal; } int solution(int n) { return conv..

정렬하고, 달라지는 지점을 하나씩 더하면, 내가 고를 수 있는 방법의 가지수가 된다. 내가 고를 수 있는 수와 같으면 return. #include #include using namespace std; int solution(vector nums) { int answer = 1; sort(nums.begin(),nums.end()); for(int i =0; i < nums.size()-1; i++){ if(answer == (nums.size()/2)) return answer; if(nums[i]!=nums[i+1]) answer++; } return answer; } unordered set을 왜 생각못했을까. 아래는 unordered set을 활용한 다른 사람의 풀이. 1. 중복을 허용하지 않는다..

여기서는 배울 점이 크게 2가지가 있다. 1) unordered_map에 데이터를 넣는법(stirng,int pair한정)과, 2) 콜론(:)과 auto를 활용한 for문 작성법. 1)unordered_map에 데이터를 넣는법 vector container 쓸때는 push_back해서 뒤에서부터 차례로 넣었는데, map은 (string, int) pair일 경우, x[key]++; 하면 그냥 넣어진다. int의 경우 값을 지정하지 않으면 default로 0이 저장되어 잇나보다. 2)콜론(:)과 auto를 활용한 for문 작성법 ' : ' 내가 반복자로 쓸 데이터타입과 변수명을 지정하고, 그 반복자를 적용할 집합?만 지정해주면 된다. string 변수명 : 적용할 집합 for( string name : p..

#include #include using namespace std; string solution(vector table, vector languages, vector preference) { string answer = ""; vectortemp; int baseScore = 6; int intermSum = 0; int highScore = 0; for (int i = 0; i < table.size(); i++) { string word = ""; for (int p = 0; p < table[i].size(); p++) { if (table[i][p] != ' ') { word += table[i][p]; if (p == table[i].size() - 1) temp.push_back(word);..