Shortest Sub Array

Shortest Sub Array

Given two array (longer and shorter), Find shortest subarray in longest array that has all elements of shorter array.
Algorithm:
  1. Create a array with size shorter_array_size X longer_array_size
  2. It will last occurrence of each elements of shorter_array in longer_array
  3. Create a closure array from array
  4. And in closure array find min difference

Latest Source Code:
Github: ShortestSubArray.java


Output:

 Big Array: [7, 5, 9, 0, 2, 1, 3, 5, 7, 9, 1, 1, 5, 8, 8, 9, 7]
Small Array: [1, 5, 9]
Shortest Sub Array : Result{start=7, end=10}
Author: Hrishikesh Mishra