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

🔑 arr[i]을 key로 하는 map을 만들고, count for every occurence of such key. 그리고, occurence, 즉 map의 value 값이 동일한지 확인하기 위해, set에 value를 넣고, set의 size와 map의 사이즈가 동일하면 true, 아니면 false를 return 한다. unique는 set을 떠올릴 것. class Solution { public: bool uniqueOccurrences(vector& arr) { // vectorcheck; // sort(arr.begin(),arr.end()); // int tmp = arr[0]; // int cnt = 1; // for(int i =1; i

🔑 각 컬럼의 최댓값과, 각 로우의 최소값에 해당하는 저장소를 각각 만들고, 서로 같은 수가 있으면 return. class Solution { public: vector luckyNumbers (vector& matrix) { int rowSize = matrix.size(); int colSize = matrix[0].size(); vectorcolMax; vectorrowMin; vectorres; for(int j =0; j < colSize; j++){ int tmp=INT_MIN; for(int i =0; i tmp) tmp = matrix[i][j]; } colMax.push_back(tmp); cout

🔑 cpdomain의 각 요소마다, parsing에 의해 생성되는 string을 key로, 선두에 나타나는 숫자를 value로 가지는 map을 생성하면 된다. 단, key가 이미 존재하는 경우, 기존 value에 신규 value를 누적 덧셈한다. class Solution { public: vector subdomainVisits(vector& cpdomains) { vectorres; mapm; for(int i =0; i

이제 트리구조 포인팅이 어떻게 되는지 스스로 생각 가능해진다. 🔑 각 recursion의 max값을 저장하여, 현재 노드 val과 비교한다. 그리고 노드val >=max이면, res++. 주의. max값은 각 recursion에 속해야 한다. (global로 max값을 설정하면 안됨!) /** * 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(..

처음으로 map을 자연스럽게 써보았다. 🔑 주어진 번호를 쪼개서, key값을 만든다음, 그 key의 value를 1씩 늘려준다. 그리고 map에서 최대값을 찾는다. class Solution { public: int countBalls(int lowLimit, int highLimit) { mapm; for(int i=lowLimit; i

🔑 isdigit으로 숫자만 추출한 다음, 대소 비교를 한다. class Solution { public: bool areNumbersAscending(string s) { bool res = true; string tmp = ""; int min = -1; for(int i =0; i min){ min = tmpInt; tmp = ""; }else{ return false; } } } return res; } };

🔑 1. next_permutation STL을 활용하여, 주어진 수 다음의 최소값을 찾는다. 2. swap 횟수를 찾는다. 1) 주어진 값과, wonderful number값 두개를 일렬로 놓는다. 2) 각 자리수를 비교( i , j ) 하며, 같은 값을 찾을 때 까지, 주어진 값의 index를 이동( j-- )시킨다. 3) 이동된 index에 해당하는 값( org[j] )이, wonderful[i]와 같을 때 까지, swap한다. swap횟수만큼 res++ class Solution { public: int getMinSwaps(string num, int k) { int res =0; string org = num; for(int i =0; i=0; i--){ int j = i; while(num[..