DCP-97: Hide and Seek Back to All Problems

Medium Data Structures > Orthogonal Range Search


**Maruf**, **Tawsif**, **Jubair** and I (**Feroz**) are four close friends. We have lots of similarities. We are studying at IIT (DU) and we are very interested in programming. Well, one more interesting fact is we all love to play hide and seek game. There are **N** rooms in a line in IIT and each room is favourite to exactly one of us. While playing game each of us hide ourselves in one of his favourite rooms. To have much fun we try to be as close as possible. Can you answer what's the minimum range of rooms that we can hide ourselves? Input: ------ Input starts with an integer **T (1<=20)**, denoting the number of test cases. Each case contains an integer **N (4 ≤ N ≤ 100000)** denoting the number of rooms. The next line will contain **N** characters denoting which of us like this room. Each of these characters will be one of first letters of our names. It is guaranteed solution always exists. Output: ------- For each case of input, output the minimum length of the room range that we can hide ourselves. Sample Input ------------ 2 7 TMFMFJJ 5 FMTJM Sample Output ------------- 6 4


Problem Setter:

Feroz Ahmmed

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# 1.00
Go 1.00
Java 1.00
JavaScript 1.00
Objective-C 1.00
Perl 1.00
PHP 1.00
Python 1.00
Python3 1.00
Ruby 1.00
VB.Net 1.00

Problem Stats

132/289

Solve/Submission

Ranking

# User Language Timing
01 Sarwar05 Cpp 0.00s
02 seyedssz Cpp14 0.00s
03 int_elligent Cpp 0.00s
04 Frdhsn Cpp 0.00s
05 TarikulCSE Cpp14 0.00s
06 shakil2021 Cpp 0.00s
07 twyu0721 Cpp 0.00s
08 Meheraj_Hossain Cpp14 0.00s
09 Tarikul_Topu Cpp14 0.00s
10 clkjwdhc Cpp 0.01s
11 sk23 Cpp 0.01s
12 Morass Cpp14 0.01s
13 monir769 Cpp14 0.01s
14 feodorv C 0.01s
15 anik_JU Cpp 0.01s
16 pulak_ict_mbstu Cpp14 0.01s
17 rayhan50001 Cpp14 0.01s
18 tariqiitju Cpp14 0.01s
19 robin_aust Cpp14 0.01s
20 mir003 Cpp 0.02s
21 ehsan_sshuvo96 Cpp 0.02s
22 devcoder CSharp 0.04s
23 sakib_muhit Cpp14 0.04s
24 RandyWaterhouse Python3 0.06s
25 Zeronfinity Cpp14 0.07s
26 emrul Cpp14 0.14s
27 mir_lutfur_rahman Cpp14 0.15s
28 PKP_007 Cpp14 0.18s
29 nasif2587 Cpp14 0.19s
30 Robbinb1993 Cpp 0.19s
31 MASUDUR_RAHMAN Cpp14 0.24s
32 prantacse14 Cpp14 0.32s
33 moinul_shaon Cpp14 0.32s
34 mtmohim Cpp14 0.34s
35 underSpirit Cpp14 0.36s
36 mamun4122 Cpp14 0.36s
37 dipta007 Cpp14 0.37s
38 bishal_biswas Cpp14 0.38s
39 abuasifkhan Cpp14 0.39s
40 Skyfall009 Cpp14 0.40s
41 froghramar Cpp14 0.40s
42 mehadi_sust Cpp14 0.41s
43 clcrr Cpp14 0.46s
44 abid1 Cpp14 0.47s
45 evan Cpp14 0.48s
46 shuvo_iu Cpp14 0.48s
47 ahqmrf Cpp14 0.48s
48 Foyaz05 Cpp14 0.48s
49 as_couple Cpp14 0.49s
50 copy_king Cpp14 0.49s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support