Only one by one
All submissions for this problem are available.
Maiya like strings which are in flip flop in nature. For example, he likes XYXY, while he doesn't like XXYX. Now he want to convert every string into a string which he likes. for this, he can only delete the character in the string.
Now find the minimum number of delete operation which is required to covert a string that Maiya likes.
The first line contains an integer T i.e the number of test cases. Next T lines contain a string each.
For each test case, print the minimum delete operation required.
- 1 ≤ T ≤ 10
- 1 ≤ Length of the string ≤ 105
Input: 5 XXXX YYYYY XYXYXYXY YXYXYX XXXYYY Output: 3 4 0 0 4
XXXX => X, 3 deletions YYYYY => Y, 4 deletions XYXYXYXY => XYXYXYXY, 0 deletions YXYXYXYX => YXYXYXYX, 0 deletions XXXYYY => XY, 4 deletions
|Time Limit:||0.02 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions