Easy data structure and algorithm practice puzzle.
Given a grid's rows and columns, a cell's row r and column c, and whether it's stored row-major, return how many spots from the start that cell is in memory. Row-major (C, NumPy) stores row by row, so it's r x cols + c. Column-major (Fortran, MATLAB) stores column by column, so it's c x rows + r. Looping in the wrong order can be several times slower.
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