Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions problems/range-addition-ii/range_addition_ii.go
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
package problem598

func maxCount(m int, n int, ops [][]int) int {
for _, op := range ops {
if m > op[0] {
m = op[0]
}
if n > op[1] {
n = op[1]
}
}
return m * n
}
29 changes: 29 additions & 0 deletions problems/range-addition-ii/range_addition_ii_test.go
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
package problem598

import "testing"

type testType struct {
m int
n int
ops [][]int
want int
}

func TestMaxCount(t *testing.T) {
tests := [...]testType{
{
m: 3,
n: 3,
ops: [][]int{
{2, 2},
{3, 3},
},
want: 4,
},
}
for _, tt := range tests {
got := maxCount(tt.m, tt.n, tt.ops)
if got != tt.want {
t.Fatalf("in: %v, got: %v, want: %v", tt.m, got, tt.want)
}
}
}