Blognawa
시작페이지로 | 검색공급자추가

뜨는 UCC 동영상더보기

t
t
t
>>"쿠케캬캬 개발 기록" 님의 최신글 리스트rss인기글
LeetCode 752. Open the Lock ( 쿠케캬캬 개발 기록 List | 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

LeetCode 2997. Minimum Number of Operations to Make Array XOR Equal to K ( 쿠케캬캬 개발 기록 List | 24-04-29 22:40 )

https://leetcode.com/problems/minimum-number-of-operations-to-mak​e-array-xor-equal-to-k nums의 모든 수를 XOR 연산해줍니다. 그 결과와 k의 특정 비트가 다르다면, nums에서 아무 수의 해당 비트를 한 번 플립해주면 됩니다. class Solution { public: int mi... Tag: Algorithm, leetcode

LeetCode 404. Sum of Left Leaves ( 쿠케캬캬 개발 기록 List | 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

LeetCode 623. Add One Row to Tree ( 쿠케캬캬 개발 기록 List | 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

LeetCode 463. Island Perimeter ( 쿠케캬캬 개발 기록 List | 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

LeetCode 200. Number of Islands ( 쿠케캬캬 개발 기록 List | 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

LeetCode 1992. Find All Groups of Farmland ( 쿠케캬캬 개발 기록 List | 24-04-20 17:55 )

https://leetcode.com/problems/find-all-groups-of-farmland/descrip​tion land를 순회하며 직사각형의 좌측상단 꼭짓점인지 판별하고, 해당 지점에서 우측하단 꼭짓점을 찾아줍니다. class Solution { public: vector<vector<int>> findFarmland(vector<vector<i... Tag: Algorithm, leetcode

LeetCode 1971. Find if Path Exists in Graph ( 쿠케캬캬 개발 기록 List | 24-04-21 14:42 )

https://leetcode.com/problems/find-if-path-exists-in-graph/descri​ption union find를 이용하여 풀었습니다. 주어진 간선들을 이용하여 노드를 그룹화해주고, source와 destination이 같은 그룹인지 확인해줍니다. class Solution { public: int p[200000]; bool... Tag: Algorithm, leetcode

LeetCode 310. Minimum Height Trees ( 쿠케캬캬 개발 기록 List | 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

LeetCode 58. Length of Last Word ( 쿠케캬캬 개발 기록 List | 24-04-04 19:46 )

<p data-ke-size="size16"><a href="https://leetcode.com/problems/length-of-last-word/desc​ription/?" target="_blank" rel="noopener noreferrer">https://leetcode.com/problems/length-of-last-​word</a></p> <p... Tag: Algorithm, leetcode

LeetCode 205. Isomorphic Strings ( 쿠케캬캬 개발 기록 List | 24-04-04 19:46 )

<p data-ke-size="size16"><a href="https://leetcode.com/problems/isomorphic-strings/"​; target="_blank" rel="noopener noreferrer">https://leetcode.com/problems/isomorphic-stri​ngs/</a></p> <p data-ke-siz... Tag: Algorithm, leetcode

LeetCode 79. Word Search ( 쿠케캬캬 개발 기록 List | 24-04-04 19:46 )

<p data-ke-size="size16"><a href="https://leetcode.com/problems/word-search/description&​quot; target="_blank" rel="noopener noreferrer">https://leetcode.com/problems/word-search/des​cription</a></p> <p data-ke-size="... Tag: Algorithm, leetcode

LeetCode 1614. Maximum Nesting Depth of the Parentheses ( 쿠케캬캬 개발 기록 List | 24-04-04 19:46 )

<p data-ke-size="size16"><a href="https://leetcode.com/problems/maximum-nesting-depth-of​-the-parentheses/" target="_blank" rel="noopener noreferrer">https://leetcode.com/problems/maximum-nesting​-depth-of-... Tag: Algorithm, leetcode

LeetCode 238. Product of Array Except Self ( 쿠케캬캬 개발 기록 List | 24-03-16 15:09 )

반응형 https://leetcode.com/problems/product-of-array-except-self O(1)의 공간으로 나눗셈 연산 없이 해결해야 합니다. i번째를 제외한 좌/우측의 prefix product를 구해주면 됩니다. res[i] = 좌_prefix_product[i] * 우_prefix_product[i] class Solution { ... Tag: Algorithm, leetcode

LeetCode 525. Contiguous Array ( 쿠케캬캬 개발 기록 List | 24-03-16 15:37 )

반응형 https://leetcode.com/problems/contiguous-array/description nums[i]가 1이라면 1을, 0이라면 -1을 변수에 더해줍니다. 그리고 각 합에 대한 인덱스를 map에 기억해줍니다. 이후에 순회하면서 해당 합을 다시 가지게 된다면,... Tag: Algorithm, leetcode

<<이전10 <이전  1 | 2  다음다음10>>
t