Tutorial by Examples

Sliding window algorithm is used to perform required operation on specific window size of given large buffer or array. Window starts from the 1st element and keeps shifting right by one element. The objective is to find the minimum k numbers present in each window. This is commonly know as Sliding w...
public class SlidingWindow { public static int[] MaxSlidingWindow(int[] input, int k) { int[] result = new int[input.Length - k + 1]; for (int i = 0; i <= input.Length - k; i++) { var max = input[i]; for (int j = 1; j < k; j++) ...

Page 1 of 1