Skip to content

Commit e8ee5d8

Browse files
authored
chore: update solutions to lc problem: No.3242 (#3733)
No.3242.Design Neighbor Sum Service
1 parent 02e7ff7 commit e8ee5d8

File tree

7 files changed

+63
-63
lines changed

7 files changed

+63
-63
lines changed

solution/3200-3299/3242.Design Neighbor Sum Service/README.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ tags:
109109
#### Python3
110110

111111
```python
112-
class neighborSum:
112+
class NeighborSum:
113113

114114
def __init__(self, grid: List[List[int]]):
115115
self.grid = grid
@@ -135,21 +135,21 @@ class neighborSum:
135135
return self.cal(value, 1)
136136

137137

138-
# Your neighborSum object will be instantiated and called as such:
139-
# obj = neighborSum(grid)
138+
# Your NeighborSum object will be instantiated and called as such:
139+
# obj = NeighborSum(grid)
140140
# param_1 = obj.adjacentSum(value)
141141
# param_2 = obj.diagonalSum(value)
142142
```
143143

144144
#### Java
145145

146146
```java
147-
class neighborSum {
147+
class NeighborSum {
148148
private int[][] grid;
149149
private final Map<Integer, int[]> d = new HashMap<>();
150150
private final int[][] dirs = {{-1, 0, 1, 0, -1}, {-1, 1, 1, -1, -1}};
151151

152-
public neighborSum(int[][] grid) {
152+
public NeighborSum(int[][] grid) {
153153
this.grid = grid;
154154
int m = grid.length, n = grid[0].length;
155155
for (int i = 0; i < m; ++i) {
@@ -181,8 +181,8 @@ class neighborSum {
181181
}
182182

183183
/**
184-
* Your neighborSum object will be instantiated and called as such:
185-
* neighborSum obj = new neighborSum(grid);
184+
* Your NeighborSum object will be instantiated and called as such:
185+
* NeighborSum obj = new NeighborSum(grid);
186186
* int param_1 = obj.adjacentSum(value);
187187
* int param_2 = obj.diagonalSum(value);
188188
*/
@@ -191,9 +191,9 @@ class neighborSum {
191191
#### C++
192192

193193
```cpp
194-
class neighborSum {
194+
class NeighborSum {
195195
public:
196-
neighborSum(vector<vector<int>>& grid) {
196+
NeighborSum(vector<vector<int>>& grid) {
197197
this->grid = grid;
198198
int m = grid.size(), n = grid[0].size();
199199
for (int i = 0; i < m; ++i) {
@@ -230,8 +230,8 @@ private:
230230
};
231231

232232
/**
233-
* Your neighborSum object will be instantiated and called as such:
234-
* neighborSum* obj = new neighborSum(grid);
233+
* Your NeighborSum object will be instantiated and called as such:
234+
* NeighborSum* obj = new NeighborSum(grid);
235235
* int param_1 = obj->adjacentSum(value);
236236
* int param_2 = obj->diagonalSum(value);
237237
*/
@@ -240,32 +240,32 @@ private:
240240
#### Go
241241
242242
```go
243-
type neighborSum struct {
243+
type NeighborSum struct {
244244
grid [][]int
245245
d map[int][2]int
246246
dirs [2][5]int
247247
}
248248
249-
func Constructor(grid [][]int) neighborSum {
249+
func Constructor(grid [][]int) NeighborSum {
250250
d := map[int][2]int{}
251251
for i, row := range grid {
252252
for j, x := range row {
253253
d[x] = [2]int{i, j}
254254
}
255255
}
256256
dirs := [2][5]int{{-1, 0, 1, 0, -1}, {-1, 1, 1, -1, -1}}
257-
return neighborSum{grid, d, dirs}
257+
return NeighborSum{grid, d, dirs}
258258
}
259259
260-
func (this *neighborSum) AdjacentSum(value int) int {
260+
func (this *NeighborSum) AdjacentSum(value int) int {
261261
return this.cal(value, 0)
262262
}
263263
264-
func (this *neighborSum) DiagonalSum(value int) int {
264+
func (this *NeighborSum) DiagonalSum(value int) int {
265265
return this.cal(value, 1)
266266
}
267267
268-
func (this *neighborSum) cal(value, k int) int {
268+
func (this *NeighborSum) cal(value, k int) int {
269269
p := this.d[value]
270270
s := 0
271271
for q := 0; q < 4; q++ {
@@ -278,7 +278,7 @@ func (this *neighborSum) cal(value, k int) int {
278278
}
279279
280280
/**
281-
* Your neighborSum object will be instantiated and called as such:
281+
* Your NeighborSum object will be instantiated and called as such:
282282
* obj := Constructor(grid);
283283
* param_1 := obj.AdjacentSum(value);
284284
* param_2 := obj.DiagonalSum(value);
@@ -288,7 +288,7 @@ func (this *neighborSum) cal(value, k int) int {
288288
#### TypeScript
289289

290290
```ts
291-
class neighborSum {
291+
class NeighborSum {
292292
private grid: number[][];
293293
private d: Map<number, [number, number]> = new Map();
294294
private dirs: number[][] = [
@@ -326,8 +326,8 @@ class neighborSum {
326326
}
327327

328328
/**
329-
* Your neighborSum object will be instantiated and called as such:
330-
* var obj = new neighborSum(grid)
329+
* Your NeighborSum object will be instantiated and called as such:
330+
* var obj = new NeighborSum(grid)
331331
* var param_1 = obj.adjacentSum(value)
332332
* var param_2 = obj.diagonalSum(value)
333333
*/

solution/3200-3299/3242.Design Neighbor Sum Service/README_EN.md

+21-21
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ In terms of time complexity, initializing the hash table has a time complexity o
107107
#### Python3
108108

109109
```python
110-
class neighborSum:
110+
class NeighborSum:
111111

112112
def __init__(self, grid: List[List[int]]):
113113
self.grid = grid
@@ -133,21 +133,21 @@ class neighborSum:
133133
return self.cal(value, 1)
134134

135135

136-
# Your neighborSum object will be instantiated and called as such:
137-
# obj = neighborSum(grid)
136+
# Your NeighborSum object will be instantiated and called as such:
137+
# obj = NeighborSum(grid)
138138
# param_1 = obj.adjacentSum(value)
139139
# param_2 = obj.diagonalSum(value)
140140
```
141141

142142
#### Java
143143

144144
```java
145-
class neighborSum {
145+
class NeighborSum {
146146
private int[][] grid;
147147
private final Map<Integer, int[]> d = new HashMap<>();
148148
private final int[][] dirs = {{-1, 0, 1, 0, -1}, {-1, 1, 1, -1, -1}};
149149

150-
public neighborSum(int[][] grid) {
150+
public NeighborSum(int[][] grid) {
151151
this.grid = grid;
152152
int m = grid.length, n = grid[0].length;
153153
for (int i = 0; i < m; ++i) {
@@ -179,8 +179,8 @@ class neighborSum {
179179
}
180180

181181
/**
182-
* Your neighborSum object will be instantiated and called as such:
183-
* neighborSum obj = new neighborSum(grid);
182+
* Your NeighborSum object will be instantiated and called as such:
183+
* NeighborSum obj = new NeighborSum(grid);
184184
* int param_1 = obj.adjacentSum(value);
185185
* int param_2 = obj.diagonalSum(value);
186186
*/
@@ -189,9 +189,9 @@ class neighborSum {
189189
#### C++
190190

191191
```cpp
192-
class neighborSum {
192+
class NeighborSum {
193193
public:
194-
neighborSum(vector<vector<int>>& grid) {
194+
NeighborSum(vector<vector<int>>& grid) {
195195
this->grid = grid;
196196
int m = grid.size(), n = grid[0].size();
197197
for (int i = 0; i < m; ++i) {
@@ -228,8 +228,8 @@ private:
228228
};
229229

230230
/**
231-
* Your neighborSum object will be instantiated and called as such:
232-
* neighborSum* obj = new neighborSum(grid);
231+
* Your NeighborSum object will be instantiated and called as such:
232+
* NeighborSum* obj = new NeighborSum(grid);
233233
* int param_1 = obj->adjacentSum(value);
234234
* int param_2 = obj->diagonalSum(value);
235235
*/
@@ -238,32 +238,32 @@ private:
238238
#### Go
239239
240240
```go
241-
type neighborSum struct {
241+
type NeighborSum struct {
242242
grid [][]int
243243
d map[int][2]int
244244
dirs [2][5]int
245245
}
246246
247-
func Constructor(grid [][]int) neighborSum {
247+
func Constructor(grid [][]int) NeighborSum {
248248
d := map[int][2]int{}
249249
for i, row := range grid {
250250
for j, x := range row {
251251
d[x] = [2]int{i, j}
252252
}
253253
}
254254
dirs := [2][5]int{{-1, 0, 1, 0, -1}, {-1, 1, 1, -1, -1}}
255-
return neighborSum{grid, d, dirs}
255+
return NeighborSum{grid, d, dirs}
256256
}
257257
258-
func (this *neighborSum) AdjacentSum(value int) int {
258+
func (this *NeighborSum) AdjacentSum(value int) int {
259259
return this.cal(value, 0)
260260
}
261261
262-
func (this *neighborSum) DiagonalSum(value int) int {
262+
func (this *NeighborSum) DiagonalSum(value int) int {
263263
return this.cal(value, 1)
264264
}
265265
266-
func (this *neighborSum) cal(value, k int) int {
266+
func (this *NeighborSum) cal(value, k int) int {
267267
p := this.d[value]
268268
s := 0
269269
for q := 0; q < 4; q++ {
@@ -276,7 +276,7 @@ func (this *neighborSum) cal(value, k int) int {
276276
}
277277
278278
/**
279-
* Your neighborSum object will be instantiated and called as such:
279+
* Your NeighborSum object will be instantiated and called as such:
280280
* obj := Constructor(grid);
281281
* param_1 := obj.AdjacentSum(value);
282282
* param_2 := obj.DiagonalSum(value);
@@ -286,7 +286,7 @@ func (this *neighborSum) cal(value, k int) int {
286286
#### TypeScript
287287

288288
```ts
289-
class neighborSum {
289+
class NeighborSum {
290290
private grid: number[][];
291291
private d: Map<number, [number, number]> = new Map();
292292
private dirs: number[][] = [
@@ -324,8 +324,8 @@ class neighborSum {
324324
}
325325

326326
/**
327-
* Your neighborSum object will be instantiated and called as such:
328-
* var obj = new neighborSum(grid)
327+
* Your NeighborSum object will be instantiated and called as such:
328+
* var obj = new NeighborSum(grid)
329329
* var param_1 = obj.adjacentSum(value)
330330
* var param_2 = obj.diagonalSum(value)
331331
*/

solution/3200-3299/3242.Design Neighbor Sum Service/Solution.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
class neighborSum {
1+
class NeighborSum {
22
public:
3-
neighborSum(vector<vector<int>>& grid) {
3+
NeighborSum(vector<vector<int>>& grid) {
44
this->grid = grid;
55
int m = grid.size(), n = grid[0].size();
66
for (int i = 0; i < m; ++i) {
@@ -37,8 +37,8 @@ class neighborSum {
3737
};
3838

3939
/**
40-
* Your neighborSum object will be instantiated and called as such:
41-
* neighborSum* obj = new neighborSum(grid);
40+
* Your NeighborSum object will be instantiated and called as such:
41+
* NeighborSum* obj = new NeighborSum(grid);
4242
* int param_1 = obj->adjacentSum(value);
4343
* int param_2 = obj->diagonalSum(value);
4444
*/

solution/3200-3299/3242.Design Neighbor Sum Service/Solution.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
type neighborSum struct {
1+
type NeighborSum struct {
22
grid [][]int
33
d map[int][2]int
44
dirs [2][5]int
55
}
66

7-
func Constructor(grid [][]int) neighborSum {
7+
func Constructor(grid [][]int) NeighborSum {
88
d := map[int][2]int{}
99
for i, row := range grid {
1010
for j, x := range row {
1111
d[x] = [2]int{i, j}
1212
}
1313
}
1414
dirs := [2][5]int{{-1, 0, 1, 0, -1}, {-1, 1, 1, -1, -1}}
15-
return neighborSum{grid, d, dirs}
15+
return NeighborSum{grid, d, dirs}
1616
}
1717

18-
func (this *neighborSum) AdjacentSum(value int) int {
18+
func (this *NeighborSum) AdjacentSum(value int) int {
1919
return this.cal(value, 0)
2020
}
2121

22-
func (this *neighborSum) DiagonalSum(value int) int {
22+
func (this *NeighborSum) DiagonalSum(value int) int {
2323
return this.cal(value, 1)
2424
}
2525

26-
func (this *neighborSum) cal(value, k int) int {
26+
func (this *NeighborSum) cal(value, k int) int {
2727
p := this.d[value]
2828
s := 0
2929
for q := 0; q < 4; q++ {
@@ -36,7 +36,7 @@ func (this *neighborSum) cal(value, k int) int {
3636
}
3737

3838
/**
39-
* Your neighborSum object will be instantiated and called as such:
39+
* Your NeighborSum object will be instantiated and called as such:
4040
* obj := Constructor(grid);
4141
* param_1 := obj.AdjacentSum(value);
4242
* param_2 := obj.DiagonalSum(value);

solution/3200-3299/3242.Design Neighbor Sum Service/Solution.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
class neighborSum {
1+
class NeighborSum {
22
private int[][] grid;
33
private final Map<Integer, int[]> d = new HashMap<>();
44
private final int[][] dirs = {{-1, 0, 1, 0, -1}, {-1, 1, 1, -1, -1}};
55

6-
public neighborSum(int[][] grid) {
6+
public NeighborSum(int[][] grid) {
77
this.grid = grid;
88
int m = grid.length, n = grid[0].length;
99
for (int i = 0; i < m; ++i) {
@@ -35,8 +35,8 @@ private int cal(int value, int k) {
3535
}
3636

3737
/**
38-
* Your neighborSum object will be instantiated and called as such:
39-
* neighborSum obj = new neighborSum(grid);
38+
* Your NeighborSum object will be instantiated and called as such:
39+
* NeighborSum obj = new NeighborSum(grid);
4040
* int param_1 = obj.adjacentSum(value);
4141
* int param_2 = obj.diagonalSum(value);
4242
*/

solution/3200-3299/3242.Design Neighbor Sum Service/Solution.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class neighborSum:
1+
class NeighborSum:
22

33
def __init__(self, grid: List[List[int]]):
44
self.grid = grid
@@ -24,7 +24,7 @@ def diagonalSum(self, value: int) -> int:
2424
return self.cal(value, 1)
2525

2626

27-
# Your neighborSum object will be instantiated and called as such:
28-
# obj = neighborSum(grid)
27+
# Your NeighborSum object will be instantiated and called as such:
28+
# obj = NeighborSum(grid)
2929
# param_1 = obj.adjacentSum(value)
3030
# param_2 = obj.diagonalSum(value)

solution/3200-3299/3242.Design Neighbor Sum Service/Solution.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class neighborSum {
1+
class NeighborSum {
22
private grid: number[][];
33
private d: Map<number, [number, number]> = new Map();
44
private dirs: number[][] = [
@@ -36,8 +36,8 @@ class neighborSum {
3636
}
3737

3838
/**
39-
* Your neighborSum object will be instantiated and called as such:
40-
* var obj = new neighborSum(grid)
39+
* Your NeighborSum object will be instantiated and called as such:
40+
* var obj = new NeighborSum(grid)
4141
* var param_1 = obj.adjacentSum(value)
4242
* var param_2 = obj.diagonalSum(value)
4343
*/

0 commit comments

Comments
 (0)