Shortest Sub Array
Given two array (longer and shorter), Find shortest subarray in longest array that has all elements of shorter array.
Algorithm:
- Create a array with size shorter_array_size X longer_array_size
- It will last occurrence of each elements of shorter_array in longer_array
- Create a closure array from array
- 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}