← Questions
Sparse canvas painting with undo and redo
0
I was asked this
No reports yet. Sign in to say where you were asked it.
Implement an unbounded canvas where paint(x, y, color) sets a pixel, read(x, y) returns its color (0 if never painted), undo() reverts the latest paint not yet undone, and redo() reapplies the latest undone paint. A new paint clears the redo history, and undo or redo with nothing to act on does nothing. Store only painted pixels, and keep each paint's previous color so undo is O(1).
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
