DCP-410: Sanvi and Magical String Back to All Problems

Easy Beginners Problems > Ad-hoc


**Sanvi** called a string, **Magical String** if all the letters of the string are identical. <br>For example "**aaaa**", "**zzz**" etc are **Magical String** whereas "aaaab", "bbbbz" etc are not.<br> You are given a string consisting of **lowercase letters only**. Your task is to convert the given string into **Magical String** in minimum number of steps.<br> In each step, you may select any index of the current string and convert the letter at that index into another letter of your choice. Input: ------ Input starts with an integer **T (1<=T<=20)**, denoting the number of test cases.<br>Each case contains an integer **N (1 ≤ N ≤ 1000)** denoting the length of the given string. <br>Next line contain a string of length exactly **N**. Output: ------- For each case of input, output the the minimum number of steps needed to change the given string into Magical string. Sample Input ------------ 2 2 ab 3 aaa Sample Output ------------- 1 0 ---------- **Explanation of sample:**<br> In the first case, Sanvi can change given string to "aa" or "bb", both require 1 steps.<br> In second case, Given string is already a Magical String.


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

155/270

Solve/Submission

Ranking

# User Language Timing
01 cse_nazmul Cpp 0.00s
02 ssavi Cpp 0.00s
03 badhansen123 Cpp 0.00s
04 skmonir Cpp 0.00s
05 Jisancse Cpp 0.00s
06 emrul Cpp14 0.00s
07 Rizon_sunny Cpp 0.00s
08 Foysol_Ahmed Cpp 0.00s
09 tariqiitju Cpp 0.00s
10 Superstorm Cpp14 0.00s
11 Nur_Alam39 Cpp 0.00s
12 The_Viper Cpp 0.00s
13 aarifshuvo Cpp 0.00s
14 pulak_ict_mbstu Cpp14 0.00s
15 Anubis Cpp 0.00s
16 afzalul C 0.00s
17 Reayz Cpp 0.00s
18 Code_Hunter Cpp 0.00s
19 abd007 Cpp 0.00s
20 prottoy919 Cpp 0.00s
21 IIUC_minhazmiraz Cpp 0.00s
22 jewel_ Cpp 0.00s
23 Ansarul_14 Cpp 0.00s
24 yeamin Cpp 0.00s
25 unknown420 Cpp 0.00s
26 jayed_al_hasan Cpp 0.00s
27 _c_k_r_ Cpp 0.00s
28 milon019 C 0.00s
29 Bruteforcekid Cpp14 0.00s
30 mbstu_alamin16 Cpp 0.00s
31 Frdhsn C 0.00s
32 ariful_lu Cpp14 0.00s
33 Tufahel Cpp 0.00s
34 wajiul Cpp 0.00s
35 Abu_Bakar Cpp 0.00s
36 Dalu Cpp 0.00s
37 Shahriar_88 Cpp 0.00s
38 Tonoy Cpp14 0.00s
39 sudo_revive Cpp 0.00s
40 baibhavbista Cpp 0.00s
41 tanu_1603070 Cpp 0.00s
42 dhruba_1603088 Cpp 0.00s
43 souravahmed C 0.00s
44 Nasif_44th Cpp 0.00s
45 sk23 Cpp 0.01s
46 Gulam_Kibria Cpp 0.01s
47 introverted Cpp 0.01s
48 Zihad Cpp 0.01s
49 time1416 Cpp 0.01s
50 Ayon_neub Cpp 0.01s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support