Spreadsheet is a very popular interview question with many variations. This article discusses some requirements we may encounter during interviews.
A few common questions about the spreadsheet at first
Intuitively, a two dimensional array can be the storage but with infinite boundary, we have to use a map/dict. The map could be position to value in general or row to list or dict for row based operation.
# position -> value
{
pos1: value1,
pos2: value2
}
# row -> list
{
row1: [val11, val12, val13]
row2: [val21, val22, val23]
}
# row -> map ( col -> value)
{
row1: {
col11: val11,
col12: val12,
},
row2: {
col21: val21,
col22: val22,
}
}
For cell format, the basic one is a pure string or integer. Some advanced cell formats are equation including addition, subtraction, multiplication and division.
The cell position is most-likely defined as a digit row index and alphbat column index, e.g, ‘1A’