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

class Solution { public: vector uncommonFromSentences(string s1, string s2) { vectorres; mapm; for(int i =0; i

class Solution { public: void permu(vectornums, int i, vector&res){ if(i == nums.size()) res.push_back(nums); else { for(int j = i; j< nums.size(); j++){ swap(nums[i], nums[j]); permu(nums, i+1, res); } } } vector permute(vector& nums) { vectorres; permu(nums, 0, res); return res; } };

class Solution { public: vector generate(int numRows) { vectorres; for(int i =1; i

🔑 링크드 리스트 개념 복습. 🔑 각 리스트의 수를 정수로 만든 후에 더하면 overflow. 따라서, 각 자리수마다 즉석해서 노드를 생성해야 한다. /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */ // long long makenum (ListNode* x){ // long long res = 0; // long long te..

🔑 주어진 word 집합의 string을 mapping하여 pattern2를 만들고, pattern1과 패턴 매칭. class Solution { public: bool wordPattern(string pattern, string s) { //if pattern size ==1, there is no more to compare. so return ture. if (pattern.size()==1) return true; char c ='a'; int j=0; string pattern2 = ""; mapm; for(int i =0; i

🔑 반복되는 sum이 있을 때, 무한 루프 돌게 되는 점을 착안하여 알고리즘을 구상한다. class Solution { public: bool isHappy(long long n) { int sum =0; long long maxn =0; int cnt =0; while(1){ cnt++; while(n!=0){ sum += pow(n%10,2); n/=10; } n = sum; sum =0; if(n==maxn) return false; if(n==1) break; if(cnt>5 && n>maxn) maxn = max(n,maxn); } return true; } };

🔑 재귀함수를 이용한 전체 탐색. class Solution { public: bool res = true; void check(int x, int y, int xlimit, int ylimit, int start, vector& matrix){ if(x == xlimit || y == ylimit) return; if(start != matrix[x][y]){ res = false; } x++; y++; check(x,y,xlimit,ylimit,start,matrix); return; } bool isToeplitzMatrix(vector& matrix) { int row = matrix.size(); int col = matrix[0].size(); for(int i = 0; i

🔑 루프 기본 연습 class Solution { public: int countStudents(vector& students, vector& sandwiches) { int cnt = 0; while(1){ if(sandwiches[0] ==students[0]){ sandwiches.erase(sandwiches.begin()); students.erase(students.begin()); cnt = 0; } else{ students.push_back(students[0]); students.erase(students.begin()); cnt++; } if(cnt == students.size()) break; } return students.size(); } };