DCP-417: String Frequency Query-2 Back to All Problems

Medium Data Structures > Binary Indexed Tree


You are given a string **S**, consisting of lowercase English alphabets, you have to perform following operations on it: 1 X Y : Change the character at index X to character Y 2 Y L R : Print the total number of occurrences of character Y in the sub-string ranges from L to R. Input: ------ There will be only one input, which begins with string **S**. Then there will be integer **Q** on the next line. <br> Then, following **Q** lines will contain query of either type 1 or type 2, begins with an integer denoting type of query.<br> if query is of type 1 followed by space separated integer and character , otherwise there will be a character followed by two integers separated by space between them, as shown in above format.<br> See the sample Input/Output section for more details. Output: ------- For every query of type 2, print an integer in a line denoting the total number of character Y that occurs in sub-string from L to R. Constraints: ------- **1<=|S|<=10^5**, |S| denotes length of string S. **1<=Q<=10^5** **0<=X<=( |S|-1 )**, indexing are 0-based. **'a'<=Y<='z'** Sample Input ------------ devskill 5 2 l 0 7 2 d 0 7 1 0 l 2 l 0 7 2 d 0 7 Sample Output ------------- 2 1 3 0


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

69/271

Solve/Submission

Ranking

# User Language Timing
01 Fahim_41 Cpp14 0.05s
02 Frdhsn Cpp14 0.05s
03 alif_cse_ju Cpp 0.05s
04 feodorv C 0.06s
05 riadspartanbd Cpp14 0.06s
06 HurayraIIT Cpp 0.06s
07 Mallika_Dey Cpp 0.06s
08 Jisancse Cpp 0.06s
09 AlaminJust Cpp 0.06s
10 Ahb_arif Cpp 0.06s
11 CLown1331 Cpp14 0.07s
12 Sarwar05 Cpp 0.07s
13 Fahim_ju Cpp 0.07s
14 SakibAlamin Cpp14 0.11s
15 Pure_Protea Cpp14 0.12s
16 _c_k_r_ Cpp14 0.12s
17 m3h3d1 Cpp 0.12s
18 pencil Cpp14 0.13s
19 rezaulhsagar Cpp14 0.13s
20 sayedgkm Cpp14 0.14s
21 dmehrab06 Cpp14 0.14s
22 Riad_IIT7 Cpp 0.15s
23 mh755628 Cpp 0.15s
24 mir003 Cpp 0.18s
25 prodipdatta7 Cpp14 0.18s
26 mohibur Cpp 0.18s
27 yead_025 Cpp 0.19s
28 aaman007 Cpp 0.20s
29 obaydullahmhs Cpp 0.21s
30 sahal Cpp 0.21s
31 rakibislam1996 Cpp14 0.23s
32 sagarthecoder Cpp 0.24s
33 SAIF_IIT8_JU Cpp 0.24s
34 mahadi97 Cpp 0.25s
35 mobasshir Cpp14 0.25s
36 muradhossen Cpp 0.26s
37 badassiumoxide Cpp 0.27s
38 Faizul_BU Cpp14 0.27s
39 BlueEye Cpp14 0.29s
40 bu_hridoy Cpp 0.29s
41 emrul Cpp 0.30s
42 hamza133913 Cpp 0.32s
43 Ramprosad Cpp 0.35s
44 inam Cpp14 0.41s
45 Debasish1610177113 Cpp 0.41s
46 fr_sarker Cpp 0.44s
47 Old_kernel Cpp14 0.44s
48 Limon_88 Cpp14 0.47s
49 njrafi Cpp14 0.48s
50 Islam_Rafat Cpp 0.49s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support