Arrays and ListsSorting, linked lists, queues, and more
Two sum problem
A popular interview question that requires you to determine if two numbers in an array sum to a specific value. A solution can be written that runs in linear time.
Print the power set of a given set
Solution for printing all possible subsets of a given set.
Find all string combinations of only 0, 1 and ?
Print all possible strings of 0's and 1's where the ? is a wildcard.
Find all duplicates in an array (version 1)
Solution for finding all duplicates in an array where the elements range from 1 to n-1.
Find all duplicates in an array (version 2)
A common interview question where your goal is to find all duplicates in an array in linear time.
Stock maximum profit
Solution that explains how to calculate the maxiumum profit that could be made in a list of stock prices.
Dutch national flag sorting problem
Question and solution for sorting an array of 0's, 1's, and 2's in place and in linear time.
Implement bubble sort
Code for implementing the simple but slow sorting algorithm, bubble sort.
Insert an interval into a list of sorted disjoint intervals
Solution for inserting an interval into an already sorted list of disjoint intervals.
Subset sum problem
Important computer science question where the goal is to find a subset that sums to some number.
Implement a queue using a linked list
Solution for how to implement a queue using a linked list data structure.
Implement a queue using two stacks
Solution for how to implement a queue using the stack data structure.