Easy data structure and algorithm practice puzzle.
Given a virtual address and the page size in bytes, return the page number and the offset within that page. Every address your program uses is split this way before the hardware can find it: the page number is looked up in the page table, and the offset is carried across unchanged, because a page moves as one piece. With a page size that is a power of two the split is just the high bits and the low bits of the address.
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.
Every line of the solution comes with a note explaining why it is there, and a step by step replay shows the code running. At level 3, where you type it yourself, you can ask for an AI mock interview on this problem that ends with a hiring manager's scorecard.
Browse all 546 puzzles