class: center, middle
class: center middle
Given the head of a non-empty singly linked list of nodes with a property val
(the value of the node) and a property next
(a reference to the next node), reverse the order of the nodes. You do not need to worry about constructing the list. You may assume that the list has already been constructed for you. You may not create a new list, you must modify the original linked list and return the head of the reversed list.
FOLLOW UP: Can you solve the problem recursively/iteratively? (depending on which solution they came up with first.)
Today you will write a couple of functions to implement Breadth First Search and Depth First Search tree traversals. IMPORTANT NOTE: The tree will NOT necessarily be a Binary Tree.
breadthFirst
depthFirstPreOrder
(If time allows, have your interviewee implement DFS Post Order traversal)
Given a string, return an array of all the permutations of that string. The permutations of the string should be the same length as the original string (i.e. use each letter in the string exactly once) but do not need to be actual words. As a reminder, a permutation of a string is another string containing all characters of the original string arranged in a different order.
The array that is returned should only contain unique values
Given a non-empty array of unique integers, sort the array in ascending order using the QuickSort algorithm.
QuickSort is a popular and efficient sorting algorithm comparable to Merge Sort and Heap Sort.
QuickSort is a recursive algorithm and consists of two major steps:
- Selecting a "pivot element".
- "Partitioning" elements in the array relative to selected pivot element.