|
|
16. LeetCode 165. Compare Version Numbers
( 쿠케캬캬 개발 기록 | 24-05-03 23:13 )
|
https://leetcode.com/problems/compare-version-numbers 두 문자열에서 '.'이 나올 때까지 version integer를 구하여 비교해줍니다. 모든 '.'을 판별할 때까지 수행해줍니다. class Solution { public: int compareVersion(string version1, string version2) ... Tag: Algorithm, leetcode
|
|
17. 자본주의 - 후기
( 쿠케캬캬 개발 기록 | 24-05-03 23:17 )
|
https://product.kyobobook.co.kr/detail/S000000848997 자본주의 | EBS 자본주의 제작팀 - 교보문고 자본주의 | 우리가 반드시 알아야 할 자본주의의 진실!『자본주의』는 자본주의를 쉽게 풀어낸 방송, ‘EBS 다큐프라임 《자본주의》 5부작’을 책... Tag: 독서, 자본주의
|
|
18. LeetCode 237. Delete Node in a Linked List
( 쿠케캬캬 개발 기록 | 24-05-05 17:50 )
|
https://leetcode.com/problems/delete-node-in-a-linked-list/description singly-linked list에서 node를 제거해야하지만, 메모리에서의 제거를 의미하는 것은 아닙니다. node의 이전 포인터를 모르므로, node의 다음 포인터에 있는 val과 next를 node로 가져오면 ... Tag: Algorithm, leetcode
|
|
19. 돈의 속성 - 후기
( 쿠케캬캬 개발 기록 | 24-05-06 17:56 )
|
https://product.kyobobook.co.kr/detail/S000001913217 돈의 속성(300쇄 리커버에디션) | 김승호 - 교보문고돈의 속성(300쇄 리커버에디션) | 2020ㆍ2021ㆍ2022ㆍ2023 4년 연속 최장기 베스트셀러 80만 깨어있는 독자들이 선택한 경제경영... Tag: 독서, 돈의 속성
|
|
20. LeetCode 2487. Remove Nodes From Linked List
( 쿠케캬캬 개발 기록 | 24-05-06 20:53 )
|
https://leetcode.com/problems/remove-nodes-from-linked-list/ 재귀를 이용하여 풀었습니다. 리스트의 마지막 노드를 먼저 방문해주고, 이후 방문되는 이전 노드의 값이 더 작으면 제거해줍니다. class Solution { public: ListNode* removeNodes(ListNode* head) { r... Tag: Algorithm, leetcode
|
|
21. LeetCode 752. Open the Lock
( 쿠케캬캬 개발 기록 | 24-04-29 22:40 )
|
https://leetcode.com/problems/open-the-lock/description/ "0000"부터 target에 도달할 수 있을 때까지 BFS를 수행해주면 됩니다. 0~9999까지의 integer 값으로 변환 및 초기화하여 수행해주었습니다. class Solution { public: bool visit[10000] = {false}; boo... Tag: Algorithm, leetcode
|
|
22. LeetCode 2997. Minimum Number of Operations to Make Array XOR Equal to K
( 쿠케캬캬 개발 기록 | 24-04-29 22:40 )
|
https://leetcode.com/problems/minimum-number-of-operations-to-make-array-xor-equal-to-k nums의 모든 수를 XOR 연산해줍니다. 그 결과와 k의 특정 비트가 다르다면, nums에서 아무 수의 해당 비트를 한 번 플립해주면 됩니다. class Solution { public: int mi... Tag: Algorithm, leetcode
|
|
23. LeetCode 404. Sum of Left Leaves
( 쿠케캬캬 개발 기록 | 24-04-20 17:55 )
|
https://leetcode.com/problems/sum-of-left-leaves/ 재귀적으로 트리를 DFS 순회하며, 현재 노드가 리프/좌측 노드인지 확인해주고, 해당하는 노드들의 값을 합산해줍니다. class Solution { public: int sumOfLeftLeaves(TreeNode* root, bool left=false) { if(!r... Tag: Algorithm, leetcode
|
|
24. LeetCode 623. Add One Row to Tree
( 쿠케캬캬 개발 기록 | 24-04-20 17:55 )
|
https://leetcode.com/problems/add-one-row-to-tree/description BFS로 (depth - 1)번째 노드를 모두 찾아줍니다. val 값과 찾은 노드의 좌/우측 서브트리를 가진 노드를 생성해주고, 기존 노드의 좌/우측 서브트리로 연결해줍니다. class Solution { public: TreeNode* a... Tag: Algorithm, leetcode
|
|
25. LeetCode 463. Island Perimeter
( 쿠케캬캬 개발 기록 | 24-04-20 17:55 )
|
https://leetcode.com/problems/island-perimeter/ land cell을 찾은 지점부터 dfs를 수행해줍니다. land 범위 벗어나거나 water cell이라면 1의 길이를 더해줍니다. class Solution { public: bool visit[100][100] = {false}; int islandPerimeter(vector<... Tag: Algorithm, leetcode
|
|
26. LeetCode 200. Number of Islands
( 쿠케캬캬 개발 기록 | 24-04-20 17:55 )
|
https://leetcode.com/problems/number-of-islands/description 아직 방문하지 않은 land cell에 도달할 때마다 DFS를 수행하여, 섬에 속한 모든 land cell에 방문 표시를 해줍니다. class Solution { public: bool v[300][300] = {false}; int numIslands(vec... Tag: Algorithm, leetcode
|
|
27. LeetCode 1992. Find All Groups of Farmland
( 쿠케캬캬 개발 기록 | 24-04-20 17:55 )
|
https://leetcode.com/problems/find-all-groups-of-farmland/description land를 순회하며 직사각형의 좌측상단 꼭짓점인지 판별하고, 해당 지점에서 우측하단 꼭짓점을 찾아줍니다. class Solution { public: vector<vector<int>> findFarmland(vector<vector<i... Tag: Algorithm, leetcode
|
|
28. LeetCode 1971. Find if Path Exists in Graph
( 쿠케캬캬 개발 기록 | 24-04-21 14:42 )
|
https://leetcode.com/problems/find-if-path-exists-in-graph/description union find를 이용하여 풀었습니다. 주어진 간선들을 이용하여 노드를 그룹화해주고, source와 destination이 같은 그룹인지 확인해줍니다. class Solution { public: int p[200000]; bool... Tag: Algorithm, leetcode
|
|
29. LeetCode 310. Minimum Height Trees
( 쿠케캬캬 개발 기록 | 24-04-23 22:41 )
|
https://leetcode.com/problems/minimum-height-trees/description/ 위상정렬을 이용하여 풀 수 있었습니다. 주어진 그래프는 양방향이므로, indegree가 1인 노드들부터 순회할 때, 마지막 순번의 노드들이 MHT의 root가 됩니다. class Solution { public: vector<int> gr... Tag: Algorithm, leetcode
|
|
30. LeetCode 58. Length of Last Word
( 쿠케캬캬 개발 기록 | 24-04-04 19:46 )
|
<p data-ke-size="size16"><a href="https://leetcode.com/problems/length-of-last-word/description/?" target="_blank" rel="noopener noreferrer">https://leetcode.com/problems/length-of-last-word</a></p> <p... Tag: Algorithm, leetcode
|
|