반응형 노드2 141. Linked List Cycle 141. Linked List Cycle Linked List Cycle - LeetCode Can you solve this real interview question? Linked List Cycle - Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuo leetcode.com 싸이클로 돌아가냐아니냐를 파악하는 문제이다. 사실 노드를 컨트롤하는것이 아직도 어려워서 코드는 이해를 했지만 혼자서 풀수 있을지는 잘모르.. 2024. 2. 23. 노드 관련 컨트롤 방법 모음 허구헌날 릿코드에 트리노드문제가 나오는데 항상 헷갈려서 한번 정리하고자한다. 일단 이거라도 외우고 해보자고~ // 이진 트리 노드 정의 function TreeNode(val) { this.val = val; this.left = null; this.right = null; } // 트리 생성 const root = new TreeNode(1); root.left = new TreeNode(2); root.right = new TreeNode(3); root.left.left = new TreeNode(4); root.left.right = new TreeNode(5); // DFS를 사용하여 트리 순회 const dfs = (node) => { if (!node) return; console.log(n.. 2024. 2. 13. 이전 1 다음 반응형