Appending a slice

Report a typo

Append the sl2 slice to sl1, then return the resulting slice from the solve function.

This problem uses the reflect package to check if you properly appended the sl2 slice to the sl1 slice. However, don't be scared! to solve this task, it is not necessary for you to know how the reflect package works.

Sample Input 1:

1 2
1
2
3

Sample Output 1:

[1 2 3]
Write a program in Go
package main

import (
"fmt"
"log"
"reflect"
)

func solve(sl1, sl2 []string) []string {
sl1 = ? // append sl2 to sl1 here!

return ? // return the appended slice here!
}

// DO NOT delete or modify the contents of the main function!
func main() {
var num1, num2 int
fmt.Scanln(&num1, &num2)

sl1, sl2 := make([]string, num1), make([]string, num2)

for i := range sl1 {
fmt.Scanln(&sl1[i])
}

for i := range sl2 {
fmt.Scanln(&sl2[i])
}

if !reflect.DeepEqual(append(sl1, sl2...), solve(sl1, sl2)) {
log.Fatal("slices were not properly appended")
}
fmt.Println(solve(sl1, sl2))
}
___

Create a free account to access the full topic