Write functions to perform common operations on slices (Go's dynamic arrays). You'll implement the following functions:
FindMax- Find the maximum value in a slice of integers.RemoveDuplicates- Remove duplicate values from a slice while preserving order.ReverseSlice- Reverse the order of elements in a slice.FilterEven- Create a new slice containing only even numbers from the original slice.
func FindMax(numbers []int) int
func RemoveDuplicates(numbers []int) []int
func ReverseSlice(slice []int) []int
func FilterEven(numbers []int) []int- For all functions, a slice of integers.
FindMax- A single integer representing the maximum value.RemoveDuplicates- A slice of integers with duplicates removed.ReverseSlice- A slice of integers in reverse order.FilterEven- A slice containing only even integers.
FindMaxshould return the maximum value from the slice. If the slice is empty, return 0.RemoveDuplicatesshould preserve the original order of elements while removing duplicates.ReverseSliceshould create a new slice with elements in reverse order.FilterEvenshould return a new slice containing only even numbers.
FindMax([]int{3, 1, 4, 1, 5, 9, 2, 6})
9
RemoveDuplicates([]int{3, 1, 4, 1, 5, 9, 2, 6})
[3 1 4 5 9 2 6]
ReverseSlice([]int{1, 2, 3, 4, 5})
[5 4 3 2 1]
FilterEven([]int{1, 2, 3, 4, 5, 6})
[2 4 6]
- Fork the repository.
- Clone your fork to your local machine.
- Create a directory named after your GitHub username inside
challenge-19/submissions/. - Copy the
solution-template.gofile into your submission directory. - Implement the required functions.
- Test your solution locally by running the test file.
- Commit and push your code to your fork.
- Create a pull request to submit your solution.
Run the following command in the challenge-19/ directory:
go test -v