For the best experience, increase the window size or view on a laptop or desktop device
Last updated: Pending
Title | ||
|---|---|---|
Loading... | ||
1/1
No questions are available yet
For the best experience, increase the window size or view on a laptop or desktop device
Title | ||
|---|---|---|
Loading... | ||
The first question is very simple, just use DFS to traverse. The second question asks for a more efficient search, so I used another cache to store it, and also stored a map of parents. Later, I realized that it can be stored directly inside the Cell.
class Cell {
Integer value;
String child1;
String child2;
public Cell(Integer value, String child1, String child2) {
this.value = value;
this.child1 = child1;
this.child2 = child2;
}
}
class Spreadsheet {
public int getCellValue(String key)
public void setCell(String key, Cell cell)
}
The first question is very simple, just use DFS to traverse. The second question asks for a more efficient search, so I used another cache to store it, and also stored a map of parents. Later, I realized that it can be stored directly inside the Cell.
class Cell {
Integer value;
String child1;
String child2;
public Cell(Integer value, String child1, String child2) {
this.value = value;
this.child1 = child1;
this.child2 = child2;
}
}
class Spreadsheet {
public int getCellValue(String key)
public void setCell(String key, Cell cell)
}
Output