Input: s ="aaabc"Output: 3Explanation:
1. Operation 2: we choose `i = 1` so `c`is'a', then we remove `s[2]` as it is closest 'a' character to the right of `s[1]`.`s` becomes "aabc" after this.2. Operation 1: we choose `i = 1` so `c`is'a', then we remove `s[0]` as it is closest 'a' character to the left of `s[1]`.`s` becomes "abc" after this.
Input: s ="cbbd"Output: 3Explanation:
1. Operation 1: we choose `i = 2` so `c`is'b', then we remove `s[1]` as it is closest 'b' character to the left of `s[1]`.`s` becomes "cbd" after this.
Input: s ="baadccab"Output: 4Explanation:
1. Operation 1: we choose `i = 6` so `c`is'a', then we remove `s[2]` as it is closest 'a' character to the left of `s[6]`.`s` becomes "badccab" after this.2. Operation 2: we choose `i = 0` so `c`is'b', then we remove `s[6]` as it is closest 'b' character to the right of `s[0]`.`s` becomes "badcca" fter this.3. Operation 2: we choose `i = 3` so `c`is'c', then we remove `s[4]` as it is closest 'c' character to the right of `s[3]`.`s` becomes "badca" after this.4. Operation 1: we choose `i = 4` so `c`is'a', then we remove `s[1]` as it is closest 'a' character to the left of `s[4]`.`s` becomes "bdca" after this.
Each operation allows you to remove duplicate occurrences of a character, so the minimum possible length is the number of unique characters in the string.