Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4191d07

Browse files
author
openset
committed
Add: Range Addition II
1 parent a937658 commit 4191d07

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
11
package problem598
2+
3+
func maxCount(m int, n int, ops [][]int) int {
4+
for _, op := range ops {
5+
if m > op[0] {
6+
m = op[0]
7+
}
8+
if n > op[1] {
9+
n = op[1]
10+
}
11+
}
12+
return m * n
13+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
11
package problem598
2+
3+
import "testing"
4+
5+
type testType struct {
6+
m int
7+
n int
8+
ops [][]int
9+
want int
10+
}
11+
12+
func TestMaxCount(t *testing.T) {
13+
tests := [...]testType{
14+
{
15+
m: 3,
16+
n: 3,
17+
ops: [][]int{
18+
{2, 2},
19+
{3, 3},
20+
},
21+
want: 4,
22+
},
23+
}
24+
for _, tt := range tests {
25+
got := maxCount(tt.m, tt.n, tt.ops)
26+
if got != tt.want {
27+
t.Fatalf("in: %v, got: %v, want: %v", tt.m, got, tt.want)
28+
}
29+
}
30+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /