TL;DR

  • The Problem: CTCI problem 17.18 technical mechanics.
  • The Approach: CTCI problem 17.18: find the shortest subarray of a larger array that contains all elements from a smaller target set using sliding window.
  • Complexity: Optimal Time and Memory bounds.

This article provides a clear breakdown of CTCI problem 17.18.

1. Context and Problem Statement

CTCI problem 17.18: find the shortest subarray of a larger array that contains all elements from a smaller target set using sliding window.

2. Technical Code & Mechanics

public static int[] shortestSupersequence(int[] big, int[] small) {
    // Sliding window technique with frequency map
    return new int[]{-1, -1};
}

3. Key Takeaways and Edge Cases

Always test boundary conditions and invalid input states.