Skip to content

Commit

Permalink
feat: add betweenTwoSets partially
Browse files Browse the repository at this point in the history
  • Loading branch information
leometzger committed Sep 1, 2023
1 parent 05d1617 commit a73c9c0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
18 changes: 18 additions & 0 deletions implementation/between_two_sets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package implementation

// https://www.hackerrank.com/challenges/between-two-sets/problem?isFullScreen=false

func getTotalX(a []int32, b []int32) int32 {
allFactors := []int32{}

Check failure on line 6 in implementation/between_two_sets.go

View workflow job for this annotation

GitHub Actions / build

allFactors declared and not used

maxB := 0
for i := 0; i < len(b); i++ {
maxB = max(maxB, int(b[i]))
}

for i := 0; i < len(a); i++ {

}

return 0
}
37 changes: 37 additions & 0 deletions implementation/between_two_sets_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package implementation

import (
"testing"

"github.com/stretchr/testify/assert"
)

type BetweenTwoSetsTestCase struct {
a []int32
b []int32
result int32
}

func TestBetweenTwoSets(t *testing.T) {
tests := []BetweenTwoSetsTestCase{
{
a: []int32{2, 4},
b: []int32{16, 32, 96},
result: 3,
},
{
a: []int32{2, 6},
b: []int32{24, 36},
result: 2,
},
{
a: []int32{3, 4},
b: []int32{24, 48},
result: 8,
},
}

for _, test := range tests {
assert.Equal(t, test.result, getTotalX(test.a, test.b))
}
}

0 comments on commit a73c9c0

Please sign in to comment.