Skip to content

Commit c4420f5

Browse files
refactor 631
1 parent 58fcff2 commit c4420f5

File tree

1 file changed

+0
-75
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-75
lines changed

src/main/java/com/fishercoder/solutions/_631.java

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,6 @@
33
import java.util.HashMap;
44
import java.util.Stack;
55

6-
/**
7-
* 631. Design Excel Sum Formula
8-
*
9-
* Your task is to design the basic function of Excel and implement the function of sum formula.
10-
* Specifically, you need to implement the following functions:
11-
12-
Excel(int H, char W):
13-
This is the constructor.
14-
The inputs represents the height and width of the Excel form.
15-
H is a positive integer, range from 1 to 26.
16-
It represents the height.
17-
W is a character range from 'A' to 'Z'.
18-
It represents that the width is the number of characters from 'A' to W.
19-
The Excel form content is represented by a height * width 2D integer array C, it should be initialized to zero.
20-
You should assume that the first row of C starts from 1, and the first column of C starts from 'A'.
21-
22-
void Set(int row, char column, int val):
23-
Change the value at C(row, column) to be val.
24-
25-
int Get(int row, char column):
26-
Return the value at C(row, column).
27-
28-
int Sum(int row, char column, List of Strings : numbers):
29-
This function calculate and set the value at C(row, column),
30-
where the value should be the sum of cells represented by numbers.
31-
This function return the sum result at C(row, column).
32-
This sum formula should exist until this cell is overlapped by another value or another sum formula.
33-
34-
numbers is a list of strings that each string represent a cell or a range of cells.
35-
If the string represent a single cell,
36-
then it has the following format : ColRow. For example, "F7" represents the cell at (7, F).
37-
If the string represent a range of cells,
38-
then it has the following format : ColRow1:ColRow2.
39-
The range will always be a rectangle,
40-
and ColRow1 represent the position of the top-left cell,
41-
and ColRow2 represents the position of the bottom-right cell.
42-
43-
44-
Example 1:
45-
Excel(3,"C");
46-
// construct a 3*3 2D array with all zero.
47-
// A B C
48-
// 1 0 0 0
49-
// 2 0 0 0
50-
// 3 0 0 0
51-
52-
Set(1, "A", 2);
53-
// set C(1,"A") to be 2.
54-
// A B C
55-
// 1 2 0 0
56-
// 2 0 0 0
57-
// 3 0 0 0
58-
59-
Sum(3, "C", ["A1", "A1:B2"]);
60-
// set C(3,"C") to be the sum of value at C(1,"A")
61-
//and the values sum of the rectangle range whose top-left cell is C(1,"A") and bottom-right cell is C(2,"B"). Return 4.
62-
// A B C
63-
// 1 2 0 0
64-
// 2 0 0 0
65-
// 3 0 0 4
66-
67-
Set(2, "B", 2);
68-
// set C(2,"B") to be 2. Note C(3, "C") should also be changed.
69-
// A B C
70-
// 1 2 0 0
71-
// 2 0 2 0
72-
// 3 0 0 6
73-
74-
Note:
75-
You could assume that there won't be any circular sum reference.
76-
For example, A1 = sum(B1) and B1 = sum(A1).
77-
The test cases are using double-quotes to represent a character.
78-
Please remember to RESET your class variables declared in class Excel,
79-
as static/class variables are persisted across multiple test cases. Please see here for more details.
80-
*/
816
public class _631 {
827

838
public static class Solution1 {

0 commit comments

Comments
 (0)