package main
import "fmt"
func main() {
arr := []int{3, 7, 9, 0, 4, 2, 1, 8}
// Define start index and length of the subset
startIndex := 2
length := 4
// Ensure the range is valid
if startIndex + length > len(arr) {
fmt.Println("Invalid range: Subset exceeds array bounds.")
return
}
// Extract the subset using slicing
subset := arr[startIndex : startIndex+length]
fmt.Println("Subset:", subset)
}
/*
run:
Subset: [9 0 4 2]
*/