Scrivio Interview library

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
  1. How does an array differ from a linked list?Data structure basics15 min
  2. Count the pairs of elements in an array that add up to a target sum.Arrays and hashing15 min
  3. Sort an array that holds only the values 0, 1 and 2 in a single pass.Two pointers16 min
  4. Find the length of the longest substring with no repeated characters.Sliding window15 min
  5. Search for a number in a sorted array using binary search.Binary search15 min
  6. Search for an element in a sorted array that has been rotated.Binary search15 min
  7. Write code that reverses a singly linked list.Linked lists15 min
  8. Detect whether a singly linked list contains a loop.Linked lists15 min
  9. Check whether a string of brackets is balanced.Stacks and queues15 min
  10. Compute the height of a binary tree.Trees16 min
  11. Find the k-th largest element in an unsorted array.Heaps and top k15 min
  12. Count the islands of connected 1s in a binary grid.Graph traversal16 min
  13. Find the contiguous subarray with the largest sum.Dynamic programming16 min
  14. Print every permutation of the characters in a string.Backtracking16 min
  15. Design and implement an LRU cache whose get and put both run in O(1) time.Designing data structures17 min

Mark a question as done on its page and it is ticked here. Kept in this browser only.