Company: Infosys SP
Difficulty: medium
\n \n HandsOn: Minimum Operations for Character Grouping \n \n You are given a string s of length n consisting of lowercase Latin letters such that \n the number of distinct characters in s is not more than 10 .\n \n \n You can perform some operation on s such that all similar characters in s are next to each other. \n Formally speaking, your goal is to ensure that for any three indices i, j, and k \n such that (1 ≤ i < k < j ≤ n) , \\\"si = sj\\\" then \\\"sk = si\\\".\n \n \n In one operation, you can choose an index i from 1 to n, pick the character from that index, \n and insert it back wherever you want in the string such that the size of s is always the same.\n \n \n In other words, you can pick any character and put it at the first position or the last position \n or in between any two other characters so the size of s will always be the same \n (after each operation, the size of s will be n ).\n \n \n Find the minimum number of operations required to achieve your goal.\n