uber 的一个面试题

原帖地址:mitbbs

设计一个 data structure something like excel's cell.

The cell has two types: value type and formula type (sum of other cells). My design is as below.

Class Cell
{
rowId;
ColId;
type; //enum-> value or sum of other cells
Value; //if type is value, this field is the value, otherwise
meaningless
List cell; // if type is forumla, the field is used to show which
other cells are needed to sum
}

是不是还有更好的design?