일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 방통대
- 딥러닝
- mpnp
- 주정부이민
- LAA
- 선형대수
- 캐나다 영주권
- 프로그래머스
- LV1
- 마니토바
- 알고리즘
- 코딩테스트
- EOI
- 머신러닝
- 기본
- 컴퓨터과학과
- 방송통신대학교
- C++
- omscs
- 조지아텍
- 개발자
- leetcode
- MATLAB
- 매트랩
- machine learning
- zeros
- cpp
- Plotting
- Deep learning
- 온라인석사
- Today
- Total
목록LV1 (4)
Krononberg

핵심 : 주어진 조건을 꼼꼼히 확인하는가. 문제 제목은 문자열 다루기 이지만, 개인적으로 이 문제는 주어진 조건을 sensitive 하게 생각하는지를 묻는 문제이다. string size가 4또는6인지에 대한 조건은 생각안하고 넘어가기 쉽기 때문이다. isdigit, isnumber 쓰려면 #include #include #include using namespace std; bool solution(string s) { bool answer = false; if(s.size()==4 || s.size()==6) answer = true; for(int i =0; i

핵심 : 진법 변환 연습. 배운 것 : 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..

배운 점 : 1) pair의 second value로 sorting하고 싶을 때는, sort parameter에 cmp함수(외부에 작성)를 추가. 2) pair를 대입하는 STL : vector.emplace_back( i , value) 주의할점은 i는 iterator성격의 값만 넣어야 함. (링크 참고) https://www.geeksforgeeks.org/vector-emplace-function-in-c-stl/ 3) 0으로 나누면 오류남. 항상 체크할 것. #include #include #include #include using namespace std; bool cmp(const pair& a, const pair& b) { if (a.second == b.second) return a.fi..