{
  "id": 21834172,
  "title": "3934. Smallest Unique Subarray",
  "url": "https://urgent.news/2026/11/25/3934-smallest-unique-subarray",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-25T18:30:41.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/mdarifulhaque/3934-smallest-unique-subarray-23f9"
  },
  "original_language": "en",
  "account": "The problem asks to find the smallest subarray length within an integer array `nums` that does not match any other subarray in terms of length and elements. A unique subarray is one that appears only once in the array. The solution involves binary searching for the minimum possible length of such a subarray.\n\nFirst, the algorithm precomputes prefix hashes using two large prime moduli and a large base, creating a rolling hash representation for each subarray of a given length. This enables checking subarray equality in constant time O(1) after preprocessing.\n\nTo ensure minimal collision risk, the algorithm employs double hashing, combining two hash values into a single composite key using a special multiplier. This composite hash is then stored in a frequency map to count occurrences of each fingerprint.\n\nAs the algorithm iterates through all possible subarray lengths (from 1 to the length of `nums`), it counts hash frequencies and keeps track of unique subarrays (those with a frequency of 1). If such a unique subarray is found, the current length is considered valid.\n\nBecause the property of having a unique subarray of a certain length is monotonic (if a length-L subarray is unique, any larger length containing it is also unique), the algorithm can apply binary search to efficiently find the minimum valid length. This approach results in an overall time complexity of O(n log n).",
  "summary": "3934. Smallest Unique Subarray Difficulty: Hard Topics: Senior Staff , Array , Hash Table , Binary Search , Rolling Hash , Suffix Array , Hash Function , Weekly Contest 502 You are given an integer array nums . Find the minimum length of a subarray 1 that is not identical to any other subarray in nums . Return an integer denoting the minimum possible length of such a subarray . Two subarrays are…",
  "key_points": [
    "Algorithm precomputes prefix hashes using two large prime moduli",
    "Double hashing combines two hash values to minimize collision risk",
    "Binary search efficiently finds minimum valid subarray length"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}