구글2 LeetCode. Reverse Linked List [Linked List] Problem: Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL -Summary- 1. Keep track of current / prev (copy the original list in the curr and prev) 2. Update and move the head (original) 3. Return prev -Other iterative solution- # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = .. 2020. 6. 3. [Arrays] firstDuplicate - Google Problem: Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a smaller index than the second occurrence of the other number does. If there are no such elements, return -1... 2020. 5. 29. 이전 1 다음