Medium data structure and algorithm practice puzzle.
Given two 32-bit sequence numbers a and b, return true if a is newer than b. A plain comparison is wrong, because the counter wraps from 4294967295 back to 0. Instead, measure how far forward a is from b, wrapping around. If that distance is more than 0 but less than half the range (2147483648), a is newer. Equal numbers aren't newer.
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