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 Ahb_arif Cpp14 0.00s
02 _Lucifer Cpp14 0.00s
03 Nuwaisir Cpp 0.00s
04 daihan_mbstu Cpp14 0.00s
05 unknown420 Cpp 0.00s
06 Ahasan_1999 C 0.00s
07 jim_khan Cpp14 0.00s
08 kashem1993 Cpp 0.00s
09 Maliha_Chowdhury Cpp 0.00s
10 fncse Cpp 0.00s
11 souravahmed C 0.00s
12 akashkumar2 Cpp 0.00s
13 foysalislam Cpp 0.00s
14 rakib_cou Cpp 0.00s
15 ivax6 Cpp14 0.00s
16 Faisal_Al_Mamun Cpp 0.00s
17 yasirnabil534 Cpp 0.00s
18 rfnamd_ju C 0.00s
19 duet_error404 Cpp 0.00s
20 Nasif_44th C 0.00s
21 leenaiitju Cpp 0.00s
22 atiqurrahman Cpp 0.00s
23 reasad Cpp14 0.00s
24 Rabia Cpp 0.00s
25 Shiam7777777 Cpp14 0.00s
26 Nahid_1710039 C 0.00s
27 Noshin_1703086 C 0.00s
28 Bisnu039 Cpp 0.00s
29 profake Cpp 0.00s
30 shahadat191 Cpp 0.00s
31 kheya Cpp 0.00s
32 Shadman_Ibne_Saiful C 0.00s
33 ashikur_rahman Cpp 0.00s
34 FariD Cpp14 0.00s
35 audity_1703001 C 0.00s
36 Mallika_Dey Cpp 0.00s
37 aaman007 Cpp 0.01s
38 Baby_programmer C 0.01s
39 feodorv C 0.01s
40 Nayem_ Cpp14 0.01s
41 Evalir Cpp 0.01s
42 prateepm Cpp14 0.01s
43 sherlocked C 0.01s
44 CSE1604085_nishan Cpp 0.01s
45 Rio_Ron Cpp14 0.01s
46 Ruhul1975 Cpp 0.01s
47 tahmid_1703067 C 0.01s
48 milon019 Cpp 0.01s
49 Arian_Ahmed Cpp 0.01s
50 de_aztech Cpp 0.01s

Your feedback is our precious!

Or call +88 02 9853138 for support