DCP-543: Magic Word Back to All Problems

Easy Beginners Problems > Ad-hoc

In National Geographic Channel **“Beyond Magic with DMC”** is a popular show in Asia which shows the illusory realms of magic – from ESP to levitation. Magician host Drummond Money-Coutts (DMC) bends audiences’ minds with captivating tricks on the streets of London, Paris, Barcelona, Mexico City and Singapore. This time DMC is in Dhaka and roaming around. On the street DMC writes a word on paper then pick a number (N) from passerby then ask another passerby “Is it a Magic Word?” passerby replied “YES”. In addition, a magic word is a string which contains no duplicate alphabet after removing maximum any N characters. Input: ------ First line of input contains an integer **T (1<= T <= 20)** number of test cases, next T lines contains a lowercase word **S (0 < |S| <= 100000 )** and an integer **N ( 1 <= N < |S| )** number of characters to be removed. Output: ------- If the word **S** is a magic word print **“YES”** and if not then print **“NO”** without quotes. See sample I/O for more clarification. Sample Input ------------ 3 aabbccdd 4 abcdef 4 aabbcc 2 Sample Output ------------- YES YES NO

Problem Setter:

Humaun Kabir

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




# User Language Timing
01 shahadat191 Cpp 0.00s
02 kashem1993 Cpp 0.00s
03 _Lucifer Cpp14 0.00s
04 yasirnabil534 Cpp 0.00s
05 FariD Cpp14 0.00s
06 leenaiitju Cpp 0.00s
07 Ahb_arif Cpp14 0.00s
08 foysalislam Cpp 0.00s
09 fncse Cpp 0.00s
10 ivax6 Cpp14 0.00s
11 unknown420 Cpp 0.00s
12 Maliha_Chowdhury Cpp 0.00s
13 kheya Cpp 0.00s
14 ashikur_rahman Cpp 0.00s
15 Bisnu039 Cpp 0.00s
16 profake Cpp 0.00s
17 rakib_cou Cpp 0.00s
18 Rabia Cpp 0.00s
19 daihan_mbstu Cpp14 0.00s
20 Faisal_Al_Mamun Cpp 0.00s
21 reasad Cpp14 0.00s
22 akashkumar2 Cpp 0.00s
23 souravahmed C 0.00s
24 jim_khan Cpp14 0.00s
25 Nuwaisir Cpp 0.00s
26 atiqurrahman Cpp 0.00s
27 rfnamd_ju C 0.00s
28 Noshin_1703086 C 0.00s
29 Nahid_1710039 C 0.00s
30 Nasif_44th C 0.00s
31 audity_1703001 C 0.00s
32 Shadman_Ibne_Saiful C 0.00s
33 Shiam7777777 Cpp14 0.00s
34 Ahasan_1999 C 0.00s
35 duet_error404 Cpp 0.00s
36 Mallika_Dey Cpp 0.00s
37 tahmid_1703067 C 0.01s
38 yearat Cpp 0.01s
39 Aluman Cpp 0.01s
40 Phenomenal_1_Riad C 0.01s
41 Arian_Ahmed Cpp 0.01s
42 Codematters Cpp 0.01s
43 Arnob114348 C 0.01s
44 Evalir Cpp 0.01s
45 Sujanmcse5BU C 0.01s
46 joynahiid C 0.01s
47 hsn_ishrk Cpp 0.01s
48 sherlocked C 0.01s
49 rahathossain690 Cpp 0.01s
50 Old_kernel Cpp14 0.01s

Your feedback is our precious!

Or call +88 02 9853138 for support