A programming problem regarding string manipulation related programming problem of hackerrank interview preparation kit.
The problem description is as follows:
You are given a string containing characters A and B only. Your task is to change it into a string such that there are no matching adjacent characters. To do this, you are allowed to delete zero or more characters in the string.
Your task is to find the minimum number of required deletions.
For example, given the string , AABAAB remove an A at positions 0 and 3 to make ABAB in 2 deletions.
Sample Input
--------------------
5
AAAA
BBBBB
ABABABAB
BABABA
AAABBB
Sample Output
-----------------------
3
4
0
0
4
I solved this problem in java with time complexity of O(n). Let me know in the comment if you more optimized solution than that.
On this page of the site you can watch the video online Alternating Characters | HackerRank Solution in java with a duration of hours minute second in good quality, which was uploaded by the user Tech with Monir 02 September 2020, share the link with friends and acquaintances, this video has already been watched 542 times on youtube and it was liked by 4 viewers. Enjoy your viewing!