As reported: Okta SDE-2 Frontend, round 1 (React + JavaScript), online, in the company's pre-configured environment (2025). Expected: modular components, good state management, efficient computation of the maximum, minimal re-renders, and an explanation of the performance aspects.
Build a React app:
- An input takes a number
n; the app renders ann × ngrid. All cells start empty. - Clicking an empty cell fills it with
max(all numbers in the grid) + 1(so the first click writes1). - Clicking a non-empty cell sets it to
max(all numbers in the grid).
Example (n = 2)
click (0,0) -> 1 click (1,1) -> 2 click (0,0) -> 2 (current max)
[1 .] [1 .] [2 .]
[. .] [. 2] [. 2]
Clarifications
- Changing
nresets the grid. - Clicking the cell that already holds the maximum leaves it unchanged.