Minimal Unique Segments
Your team at AMZ is currently working on an innovative algorithm to generate password suggestions when users create a brand-new account.
Imagine a string composed solely of lowercase English letters that qualifies as "redundancy-free" — meaning that each individual character appears at most once within that string. To ensure minimal repetition, the developers want to suggest a password that can be split into the smallest number of these redundancy-free segments.
In this challenge, you are provided with an input string called userPassword. Your task is to determine the minimum number of segments into which userPassword can be partitioned so that every segment is redundancy-free.
Complete the function getNumberRedundancyFree in the editor.
getNumberRedundancyFree has the following parameter:
string userPassword: the given password
Returns
int: The minimum number of segments required to divide the string into redundancy-free parts :)
1Example 1

2Example 2
3Example 3
Constraints
Limits and guarantees your solution can rely on.
1 ≤ length of userPassword ≤ 10^5- All characters in
userPasswordare lowercase English letters.