Alex has a string s , made up of lowercase Latin letters. Alex wants to remove two…
- User
Alex has a string s , made up of lowercase Latin letters.
Alex wants to remove two consecutive characters from the string s , and you are curious to find out how many unique strings can be formed by this operation.
For example, if Alex's string is "aaabcc", the possible different strings are: "abcc" (by deleting the first two or second and third characters), "aacc" (by deleting the third and fourth characters), "aaac" (by deleting the fourth and fifth characters), and "aaab" (by deleting the last two characters).
Input
The first line of the input contains a single integer t (1≤t≤104 ) — the number of test cases.
Each test case consists of two lines.
The first line contains an integer n (3≤n≤2⋅105 ) — the length of the string.
The second line contains a string s of length n , consisting of lowercase Latin letters.
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
Output
For each test case, print one integer — the number of distinct strings that can be formed by removing two consecutive characters.
Example InputCopy 7 6 aaabcc 10 aaaaaaaaaa 6 abcdef 7 abacaba 6 cccfff 4 abba 5 ababa OutputCopy 4 1 5 3 3 3 1
Note
The first example is explained in the statement.
In the third example, the resulting strings are: "cdef", "adef", "abef", abcf", and "abcd".
In the seventh example, any pair of consecutive deletions will result in the string "aba".
- Assistant
To solve the problem of determining the number of unique strings that can be formed by removing two consecutive characters from a given string, we can use a hashing technique. The approach involves: