Coding patterns
Getting ready for the coding round. One solved problem for each pattern, in the order most people learn them. Each solution is worked by hand first, then drawn step by step, then written in Java.
15 questions, about 4 hours of reading
Start with the first question- How does an array differ from a linked list?
- Count the pairs of elements in an array that add up to a target sum.
- Sort an array that holds only the values 0, 1 and 2 in a single pass.
- Find the length of the longest substring with no repeated characters.
- Search for a number in a sorted array using binary search.
- Search for an element in a sorted array that has been rotated.
- Write code that reverses a singly linked list.
- Detect whether a singly linked list contains a loop.
- Check whether a string of brackets is balanced.
- Compute the height of a binary tree.
- Find the k-th largest element in an unsorted array.
- Count the islands of connected 1s in a binary grid.
- Find the contiguous subarray with the largest sum.
- Print every permutation of the characters in a string.
- Design and implement an LRU cache whose get and put both run in O(1) time.
Mark a question as done on its page and it is ticked here. Kept in this browser only.