Another substring
Practice
3.3 (3 votes)
Algorithms
Approved
Dynamic programming
Hard
Ready
Recruit
Two pointer
Problem
51% Success 631 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
7 votes
Tags:
AlgorithmsDynamic ProgrammingIntroduction to Dynamic Programming 1
Points:50
5 votes
Tags:
AlgorithmsApprovedDynamic ProgrammingGrammar-VerifiedHardHiringRecruit
Points:50
8 votes
Tags:
Introduction to Dynamic Programming 1AlgorithmsDynamic Programming
Editorial