분류 전체보기
-
Linked List | Flatten a Multilevel Doubly Linked ListAlgorithm/Linked List 2021. 5. 27. 10:16
You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in the example below. Flatten the list so that all the nodes appear in a single-level, doubly li..
-
Linked List | Add Two Numbers IIAlgorithm/Linked List 2021. 5. 27. 02:25
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers do not contain any leading zero, except the number 0 itself. 두 Linked List가 있는데, Singly Linked List이고, 더한 값을 Linked List로 리턴하라는 문제이다. 하지만 덧셈을..
-
Linked List | Odd Even Linked ListAlgorithm/Linked List 2021. 5. 24. 22:44
Given the head of a singly linked list, group all the nodes with odd indices together followed by the nodes with even indices, and return the reordered list. The first node is considered odd, and the second node is even, and so on. Note that the relative order inside both the even and odd groups should remain as it was in the input. Linked List가 주어졌을 때, 홀수번째 노드들과 짝수번째 노드들을 나누어서, 모든 홀수는 앞쪽에, 모든 짝..
-
Linked List | Swapping Nodes in a Linked ListAlgorithm/Linked List 2021. 5. 15. 20:14
You are given the head of a linked list, and an integer k. Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed). 앞에서 k번째, 그리고 뒤에서 k번째 노드의 값을 swap, 즉 바꾸라는 Medium 난이도의 문제이다. 아래와 같은 조건도 주었다. 노드의 값이 크지 않기때문에 swap하는것은 별로 큰 문제가 없겠지만, 총 리스트의 크기가 100,000 이기때문에 (컴퓨터에게는 그렇게 큰 숫자는 아니지만) 리스트를 travel 하는 숫자를 적게 하는..
-
Linked List | Merge In Between Linked ListsAlgorithm/Linked List 2021. 5. 13. 23:29
You are given two linked lists: list1 and list2 of sizes n and m respectively. Remove list1's nodes from the ath node to the bth node, and put list2 in their place. Medium 난이도의 문제이다. 두 Linked List가 주어졌을 때, list1의 a번부터 b를 삭제한 후, 삭제된 자리에 list2를 넣는 문제이다. O(N)으로 해결하기 위해 아래와 같이 접근했다. class Solution { public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) { ListNode temp = null; ..
-
도지코인, 테슬라 그리고,,,IT Daily 2021. 5. 12. 12:14
Dogecoin 오늘 매경 이슈브리핑에서는 일런머스크와 그의 회사에 대해 브리핑해주셨다. 요새 정말 이슈다. 일론머스크의 한마디에 도지코인 가격이 몇배로 뛰었다가 또 얼마전 SNL에 출연해 도지코인을 "hustle" 불렀다. 이 장난스러운 한마디에 도지코인의 가격은 급락을 하기도 한다. 몇백 몇백조의 돈을 말한마디로 움직이는 정말 엄청난 인물인 것 같다. 그러다가 몇일전, DOGE-1 Mission to the Moon 이라는 프로젝트 서비스를 도지코인으로 받겠다고 발표했다. 그의 트위터에 이에대해서 올린것인데, 친절하게 도지코인송의 링크까지 걸어주었다. Cybertruck $39,000의 가격에 살 수 있다는 테슬라의 야심작, 사이버트럭이 주행하는 영상도 화제이다. 이 사이버트럭은 테슬라의 첫번째 픽업..
-
해고, CEOIT Daily 2021. 5. 3. 11:57
5년반동안의 역임을 뒤로하고, 알파벳(구글의 모회사)의 자율주행회사인 Waymo를 이끌던 CEO, John Krafcki이 CEO의 자리에서 물러났다. 실리콘밸리에서는 CEO가 해고가 되고 바뀌는 일이 자주 일어난다. CEO란? 그 회사의 주인이 아니다. 회사의 모든 업무를 아울러야하는, 모든 구석을 알고있어야 하는 존재이다. 드라마에서 보면, 회사에 사건 사고가 생기면 말단 직원, 또는 눈총을 받은 직원이 모든 책임을 지고 퇴사를 하곤 한다. 물론, 그런일도 있지만, 실리콘밸리에서는 1000여명의 CEO들이 여러 이유에 대한 책임으로 매년 해고를 당한다 (미디어에서는 해고라기보다 자진 퇴사로 마무리하기도 한다). 미라클레터에서 소개해준 분석에 의하면, 주주들이 CEO를 해고하고 싶은 욕구가 드는때를 다..
-
Linked List | Remove Duplicates from Sorted ListAlgorithm/Linked List 2021. 5. 2. 21:07
Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well. 이미 숫자로 정렬되어있는 Linked List에서 중복되는 값을 가진 노드들을 삭제한 후, 다시 Linked List를 리턴하라는 문제이다. 리턴시에는 그 리스트의 Head를 리턴하면 된다. 이 문제는 한번의 loop으로 해결할 수 있다. class Solution { public ListNode deleteDuplicates(ListNode head) { if(head == null) return null; ListNode pivot = head; L..