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

54/202

Solve/Submission

Ranking

# User Language Timing
01 Morass Cpp14 0.09s
02 FariD Cpp14 0.10s
03 feodorv C 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 nurshuvo51 Cpp 0.28s
10 nuhu_iu Cpp 0.28s
11 ssavi Cpp 0.28s
12 subhashis_cse Cpp 0.28s
13 emrul Cpp 0.28s
14 tariqiitju Cpp 0.28s
15 Masum_ice Cpp 0.28s
16 hiddenhopes Cpp14 0.28s
17 MRITuhin Cpp 0.28s
18 mhiceiuk Cpp 0.29s
19 saiful130104 Cpp 0.29s
20 rayhan50001 Cpp 0.29s
21 AlaminJust Cpp14 0.29s
22 Saimum_140128 Cpp 0.29s
23 KIRIN_36 Cpp 0.29s
24 badhansen123 Cpp 0.29s
25 zitul_mahmud Cpp 0.29s
26 susmoys Cpp 0.29s
27 kissu_pari_na Cpp 0.29s
28 Taran 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 taskin1995 Cpp 0.81s
35 asifthegreat Cpp 0.81s
36 SakibAlamin Cpp 0.82s
37 Rajan_sust Cpp 0.82s
38 Bruteforcekid Cpp 0.82s
39 duronto20 Cpp 0.82s
40 shamimjucse Cpp 0.82s
41 Nazmul_WUB Cpp 0.82s
42 Sarwar05 Cpp 0.82s
43 pulak_ict_mbstu Cpp 0.82s
44 abufarhad Cpp 0.82s
45 mhiceiu Cpp 0.83s
46 devcoder CSharp 1.03s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support