Toy Story - Editorial

Problem Link:

Practice

Setter: saquib ul hassan

Difficulty:
EASY

Prerequisites:
Array

Problem:
There are n toys in the shelf, then find the least number of her toys that can be taken off the shelf so that no two adjacent toys have names starting with the same letter.

Quick Explanation:
We just iterate over the length of the string and if we find that s[i]==s[i+1] we set the counter variable to C=C+1, and at the end dispaly it

SOLUTION:

Setter

Time Complexity:
Lets say N is the length of string
O(N)