DCP-428: Minimum Contiguous Subarray Back to All Problems

Easy Beginners Problems > Ad-hoc


You are given an array **A** of **N** integers. You have to partition the array into minimum number of partition of contiguous sub-arrays in such a way that every sub-array has **exactly one unique element**. Input: ------ Input starts with an integer **T (1<=T<=20)**, denoting the number of test cases. Each case contains an integer **N (1 ≤ N ≤ 100000)** denoting the number of elements of array A. The next line will contain **N** integers separated by spaces, denoting the elements of the array A. Each of these integers will be in the range of 32 bit signed integer number. Output: ------- For each case of input, output the minimum number sub-arrays formed with above mentioned partition. Sample Input ------------ 2 5 1 2 4 3 5 3 1 1 2 Sample Output ------------- 5 2 Explanation:<br> In sample testcase-1, minimum partition is : 1 | 2 | 4 | 3 | 5 , So minimum sub-arrays formed are 5.<br> In sample testcase-2, minimum partition is : 1 1 | 2 , So minimum sub-arrays formed are 2. Although there could be another valid partition: 1 | 1 | 2 , but sub-arrays formed are 3.


Problem Setter:

Bishal Gautam

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C 1.00
C++ 1.00
C++14 1.00
C# 2.00
Go 2.00
Java 2.00
JavaScript 2.00
Objective-C 2.00
Perl 2.00
PHP 2.00
Python 2.00
Python3 2.00
Ruby 2.00
VB.Net 2.00

Problem Stats

55/203

Solve/Submission

Ranking

# User Language Timing
01 Morass Cpp14 0.09s
02 feodorv C 0.10s
03 FariD Cpp14 0.10s
04 kzvd4729 Cpp 0.21s
05 Chydra Cpp 0.21s
06 DynamicOvi Cpp 0.21s
07 arman_ferdous Cpp 0.22s
08 khatribiru Cpp 0.22s
09 Masum_ice Cpp 0.28s
10 ssavi Cpp 0.28s
11 nuhu_iu Cpp 0.28s
12 subhashis_cse Cpp 0.28s
13 hiddenhopes Cpp14 0.28s
14 MRITuhin Cpp 0.28s
15 tariqiitju Cpp 0.28s
16 emrul Cpp 0.28s
17 nurshuvo51 Cpp 0.28s
18 susmoys Cpp 0.29s
19 AlaminJust Cpp14 0.29s
20 KIRIN_36 Cpp 0.29s
21 kissu_pari_na Cpp 0.29s
22 Saimum_140128 Cpp 0.29s
23 Taran Cpp 0.29s
24 badhansen123 Cpp 0.29s
25 zitul_mahmud Cpp 0.29s
26 saiful130104 Cpp 0.29s
27 mhiceiuk Cpp 0.29s
28 rayhan50001 Cpp 0.29s
29 Pure_Protea Cpp 0.31s
30 Key_logger Cpp 0.32s
31 astrolion7 Cpp 0.45s
32 Mr_KAJOL Cpp 0.80s
33 Momin_just Cpp 0.81s
34 asifthegreat Cpp 0.81s
35 taskin1995 Cpp 0.81s
36 duronto20 Cpp 0.82s
37 SakibAlamin Cpp 0.82s
38 Bruteforcekid Cpp 0.82s
39 Nazmul_WUB Cpp 0.82s
40 shamimjucse Cpp 0.82s
41 Sarwar05 Cpp 0.82s
42 abufarhad Cpp 0.82s
43 pulak_ict_mbstu Cpp 0.82s
44 Rajan_sust Cpp 0.82s
45 mhiceiu Cpp 0.83s
46 Taj025 CSharp 1.01s
47 devcoder CSharp 1.03s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support