This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write code to remove duplicates from an unsorted linked list. | |
FOLLOW UP | |
How would you solve this problem if a temporary buffer is not allowed? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement an algorithm to find the kth to last element of a singly linked list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You have two numbers represented by a linked list, where each node contains a single digit. The digits are stores in reverse order, such | |
that the 1's digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list. | |
FOLLOW UP | |
Suppose the digits are stored in forward order. Repeat the above problem. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_ _ _ I t _ _ _ _ i s _ _ a _ a p p l e _ _ => I t _ i s _ a _ a p p l e |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Given three sorted interger arrays, A, B and C, find three indices (i,j,k) such that max(abs(A[i] - B[j]), abs(A[i]-C[k]), abs(B[j]-C[k])) is minimized. | |
Implement the function to return the minimal value. | |
Example: | |
A: [1,2,4,8,16,32] | |
B: [3,5,9,15,17,40] | |
C: [6,13,23,36,45] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given a circular linked list, implement an algorithm which returns the node at the begining of the loop. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement a function to check if a linked list is a palindrome. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//reverse singly linked list | |
public static Node reverseList(Node root){ | |
if(root == null) return null; | |
return reverseListHelp(root); | |
} | |
public static Node reverseListHelp(Node root){ | |
if(root.next == null) return root; | |
Node end = reverseListHelp(root.next); | |
root.next.next = root; |