Open mchirico opened 3 years ago
mchirico, Thanks for opening this issue!
func subset(seq1 []int, seq2 []int ) bool {
/* write code here */
1index :=0
2index := 0
for 1index < len(seq1) && 2index < len(seq2){
if seq1[1index] == seq2[2index] {
2index +=1
}
1index +=1
}
return 1index == len(seq1)
}
Write a Go program that takes two sequences of integers, and returns true if the 2nd sequence is a subset of the first.
The program should work for any sequence. Here is an example.
Above, seq2 is a subset of seq1.
Hints
You can do this with maps, which is one way. Below is a sample test function
Validate sequence
Possible solution
Here's what I came up with program; but, you should try it yourself first.