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

/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} * }; */ class Solution { public: TreeNode* newNode(int x){ TreeNode* tmp = new Tree..

class Solution { public: int uniqueMorseRepresentations(vector& words) { vectorcode ={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--.."}; sets; for(int i =0; i

이런 문제는 대충 디버그하면서 풀게 되면, 시간 오래 걸림. class Solution { public: int minOperations(int n) { int res =0; if(n==1||n==0){ return 0; } else{ if(n%2==0){ for(int i =0; i

string이 vector와 유사함을 착안. bool compare (string a, string b) { return a[i] == b[i] ? a < b : a[i] < b[i]; } vector solution(vector strings, int n) { i = n; sort (strings.begin(), strings.end(), compare); return strings; }

다른 사람의 풀이에서 가장 좋아요를 많이 받은 분의 코드를 공부하고, 필사해보았다. 핵심 1. 짝수여부를 bit연산자 & 1 로 판단. 2. 재귀호출 사용. #include #include using namespace std; int sign(int x, int count = 0) { for (int i = 1; i right ? 0 : sign(left) * left + solution(left + 1, right); }

나의 방식 1. 10진수의 arr1 arr2에 대해, 각각 2진수로 바꿈. 2. 각각의 2진수를 비교하여, 비밀지도 합본 완성. 3. string변환 배운것 (컴퓨터는 10진수를 2진수로 읽음에 착안. 출제자의 의도.) 1. arr1 arr2 OR 비트 연산을 통해, 비밀지도 합본 완성 2. string변환 #include #include using namespace std; vector toBinary(int x, int k){ vector v; for(int i=0; i

#include #include #include using namespace std; bool solution(string s) { bool answer = true; int count =0; for(int i =0; i

핵심 : 주어진 조건을 꼼꼼히 확인하는가. 문제 제목은 문자열 다루기 이지만, 개인적으로 이 문제는 주어진 조건을 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