Another substring
Practice
3.3 (3 votes)
Algorithms
Approved
Dynamic programming
Hard
Ready
Recruit
Two pointer
Problem
51% Success 630 Attempts 50 Points 5s Time Limit 256MB Memory 1024 KB Max Code
You are given an array \(A\). The array contains all the elements in the range of \(1\) to \(K\).
Determine the minimum size of the subarray that contains all the \(K\) distinct elements.
Input format
- First line: \(T\) denoting the number of test cases
- For each test case:
- First line: \(N\) denoting the length of the array and \(K\)
- Next line: \(N\) integers denoting the elements of the array
Output format
Print the minimum size of the subarray that contains all the \(K\) distinct elements.
Constraints
\(1 \le T \le 10\\ 1 \le N \le 100000\\ 1 \le K \le 10000\)
Submissions
Please login to view your submissions
Similar Problems
Points:50
1 votes
Tags:
Dynamic ProgrammingIntroduction to Dynamic Programming 1Algorithms
Points:50
8 votes
Tags:
Introduction to Dynamic Programming 1AlgorithmsDynamic Programming
Points:50
1 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingHardRecruit
Editorial