- need at least 3 elements relating to a particular value in order to conduct a removal operation
- could create a hashmap, where the key is the char and the value is a list of indices where the chars are located
π€What Did I Struggle With?
~
π‘ Explanation of Solution
Observation:
- if a character appears odd times --> 1 character remains
- if a character appears even times --> 2 characcters remain
- instead of tracking indices explicitly , we can just count occurences of each character
- based on the above observation, we only need to process each character once
----------------------------------------------------------------------------------
- **Create a frequency hashmap** to count occurrences of each character.
- **For each character**, determine how many will remain after applying the removal rule:
- If `freq % 2 == 1`, keep `1` character.
- If `freq % 2 == 0`, keep `2` characters.
- **Sum up the remaining counts** to get the final string length.