Medium data structure and algorithm practice puzzle.
Given the pages a program touches in order and how many frames of memory it has, return how many page faults it takes under least-recently-used replacement. On a hit the page becomes the most recent; on a miss the least recent is evicted. Evicting by ARRIVAL time instead is the bug: the oldest page is very often the one being used constantly, so the cache works worst on exactly what it should work best on.
Solve it three ways: snap the jigsaw pieces together, fill in the blanks, or type it from scratch against the tests. This one is free.
Browse all 536 puzzles