Easy data structure and algorithm practice puzzle.
Memory is one long line of addresses, so a grid has to be flattened to be stored. Given the grid's rows and columns, a cell's row and column, and whether the layout is row-major, return how many elements from the start that cell sits. C and NumPy store row by row, Fortran and MATLAB column by column, and walking a grid in the other order than it was stored is one of the most common reasons two correct loops differ in speed several times over.
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