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.
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 |
Solve/Submission
# | User | Language | Timing |
---|---|---|---|
01 | Foysol_Ahmed | Cpp | 0.00s |
02 | emrul | Cpp14 | 0.00s |
03 | dhruba_1603088 | Cpp | 0.00s |
04 | pulak_ict_mbstu | Cpp14 | 0.00s |
05 | Jisancse | Cpp | 0.00s |
06 | _c_k_r_ | Cpp | 0.00s |
07 | skmonir | Cpp | 0.00s |
08 | sudo_revive | Cpp | 0.00s |
09 | mbstu_alamin16 | Cpp | 0.00s |
10 | jewel_ | Cpp | 0.00s |
11 | jayed_al_hasan | Cpp | 0.00s |
12 | IIUC_minhazmiraz | Cpp | 0.00s |
13 | tanu_1603070 | Cpp | 0.00s |
14 | Superstorm | Cpp14 | 0.00s |
15 | Bruteforcekid | Cpp14 | 0.00s |
16 | Reayz | Cpp | 0.00s |
17 | Anubis | Cpp | 0.00s |
18 | cse_nazmul | Cpp | 0.00s |
19 | Rizon_sunny | Cpp | 0.00s |
20 | aarifshuvo | Cpp | 0.00s |
21 | The_Viper | Cpp | 0.00s |
22 | Abu_Bakar | Cpp | 0.00s |
23 | ssavi | Cpp | 0.00s |
24 | Shahriar_88 | Cpp | 0.00s |
25 | yeamin | Cpp | 0.00s |
26 | ariful_lu | Cpp14 | 0.00s |
27 | baibhavbista | Cpp | 0.00s |
28 | abd007 | Cpp | 0.00s |
29 | Frdhsn | C | 0.00s |
30 | milon019 | C | 0.00s |
31 | badhansen123 | Cpp | 0.00s |
32 | Dalu | Cpp | 0.00s |
33 | prottoy919 | Cpp | 0.00s |
34 | Tonoy | Cpp14 | 0.00s |
35 | Nur_Alam39 | Cpp | 0.00s |
36 | Ansarul_14 | Cpp | 0.00s |
37 | unknown420 | Cpp | 0.00s |
38 | afzalul | C | 0.00s |
39 | Code_Hunter | Cpp | 0.00s |
40 | Tufahel | Cpp | 0.00s |
41 | tariqiitju | Cpp | 0.00s |
42 | wajiul | Cpp | 0.00s |
43 | Nasif_44th | Cpp | 0.00s |
44 | souravahmed | C | 0.00s |
45 | Chucks | Cpp | 0.01s |
46 | Titanium_Owner | Cpp | 0.01s |
47 | Pure_Protea | Cpp14 | 0.01s |
48 | sohag_AUST | Cpp | 0.01s |
49 | time1416 | Cpp | 0.01s |
50 | feodorv | C | 0.01s |
Copyright © 2015-2016 Dev Skill.