LinkedList
-
[ LinkedList ] 876. Middle of the Linked List (JAVA)리트코드(Leetcode) 2023. 6. 8. 17:23
리트코드 JAVA로 876번 문제 풀이 1. 문제 내용 Given the head of a singly linked list, return the middle node of the linked list. If there are two middle nodes, return the second middle node. => head라는 이름의 링크드 리스트가 주어지고 그 리스트의 중간 노드를 반환하라. 만약 중간 노드가 2개라면 두 번째 노드를 반환하라. => 여기서 알 수 있는 것 : length가 홀수일 때와 짝수일 때를 구분해야 한다는 것! Example 1: Input: head = [1,2,3,4,5] Output: [3,4,5] Explanation: node 3이 중간 노드이다. Example 2..
-
[ Linked-List ] 1290. Convert Binary Number in a Linked List to Integer - JAVA리트코드(Leetcode) 2023. 6. 7. 17:31
* leetcode의 1290번 문제를 풀어보도록 하겠다. 일단 linked-list란 뭔지 알아야 풀 수 있을 것 같다. * linked-list란? 배열인데 node라는 공간에 value와 해당 node와 연결된 이웃 node 자체 값을 갖고 있는 배열이다. 링크 리스트는 이런 식으로 한 node에 value와 다음 이웃노드의 주소값이 있는 형태로 되어 서로가 연결되어 있다. 1290의 문제를 읽어보자. Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representatio..