func SlidingWindow[T any](a []T, size int) [][]T {
	if len(a) == 0 {
		return [][]T{}
	}

	if len(a) <= size {
		return [][]T{a}
	}

	// allocate slice at the precise size we need
	r := make([][]T, 0, len(a)-size+1)

	for i, j := 0, size; j <= len(a); i, j = i+1, j+1 {
		r = append(r, a[i:j])
	}

	return r
}
// SlidingWindow returns subarrays of a of size size, starting at increasing indices of a. For example,
// SlidingWindow([0 1 2 3 4 5], 3) = [[0 1 2] [1 2 3] [2 3 4] [3 4 5]].
SlidingWindow returns subarrays of a of size size, starting at increasing indices of a.
// SlidingWindow returns subarrays of a of size size starting at increasing indices of a . For example // SlidingWindow ( [ 0 1 2 3 4 5 ] 3 ) = [[ 0 1 2 ] [ 1 2 3 ] [ 2 3 4 ] [ 3 4 5 ]] .
func SlidingWindow[T any](a []T, size int) [][]T {
	if len(a) == 0 {
		return [][]T{}
	}
	if len(a) <= size {
		return [][]T{a}
	}
	r := make([][]T, 0, len(a)-size+1)
	for i, j := 0, size; j <= len(a); i, j = i+1, j+1 {
		r = append(r, a[i:j])
	}
	return r
}
func SlidingWindow [ T any ] ( a [ ] T , size int ) [ ] [ ] T { if len ( a ) == 0 { return [ ] [ ] T { } } if len ( a ) <= size { return [ ] [ ] T { a } } r := make ( [ ] [ ] T , 0 , len ( a ) - size + 1 ) for i , j := 0 , size ; j <= len ( a ) ; i , j = i + 1 , j + 1 { r = append ( r , a [ i : j ] ) } return r }
SlidingWindow returns subarrays of a of size size, starting at increasing indices of a.
SlidingWindow returns subarrays of a of size size starting at increasing indices of a .
// allocate slice at the precise size we need