Scrivio Interview library

Data structures and algorithms

100 of the coding questions asked most often in interviews, each with a full solution in Java, grouped by the pattern that solves them, so you can practise one technique at a time. Reported by candidates in public interview write-ups and reworded by Scrivio. How the reports are counted

By pattern

In the order most people learn them
Data structure basicsHow each structure works, what it costs and when to pick it7 questionsArrays and hashingCounting, frequencies, prefix sums, duplicates and anagrams9 questionsTwo pointersPairs from both ends, partitioning, reversing in place, merging4 questionsSliding windowThe longest or shortest run that meets a condition3 questionsBinary searchSorted data, rotated arrays and searching on the answer6 questionsSorting and intervalsSorting algorithms, custom order, merging and scheduling intervals6 questionsStacks and queuesBrackets, monotonic stacks, next greater element, deques5 questionsLinked listsReversal, fast and slow pointers, cycles, merging and reordering13 questionsTreesTraversals, depth, paths, views, construction and common ancestors11 questionsBinary search treesInsert, delete, validate, k-th smallest and conversions2 questionsHeaps and top kPriority queues, k-th largest, merging k lists, running median4 questionsGraph traversalBreadth-first and depth-first search, islands, components, cycles3 questionsGraph algorithmsShortest paths, topological sort, spanning trees, union-find1 questionsBacktrackingPermutations, subsets, combinations, N-Queens and word search1 questionsDynamic programmingKnapsack, subsequences, edit distance and partitions6 questionsGreedyTaking the best step each time: jumps, gas stations, scheduling1 questionsStrings and triesMatching, palindromes, prefixes and transformations5 questionsMath and bitsPrimes, GCD, digits, powers and bit tricks9 questionsMatrices and simulationSpiral order, rotation and step-by-step simulations2 questionsDesigning data structuresLRU and LFU caches, min stack, iterators, hit counters2 questions

By data structure

Most asked

Most reported first