Facebook Pixel

Amazon Online Assessment 2021 (OA) - Find Password Strength

The folks who design security strategies for online platforms have created a fresh way to gauge how strong a username is. This method works only on usernames that use lower case English alphabets. To get the strength of a username, they tally up the different kinds of alphabets used in all potential chains of characters that can be made from that username.

Here's a thing to remember: any chain of characters we take from a username has to be in the same order as in the username. Given a username, you have to find out how strong it is based on these rules.

Relevant Amazon OA Problems:

Input

  • password: the password

Output

the strength of the password

Examples

Example 1:

Input:

password = good

Output: 16

Explanation:

password-good

Thus, password strength = 1 + 1 + 1 + 1 + 2 + 1 + 2 + 2 + 3 = 16.

Example 2:

Input:

password = test

Output: 19

Explanation:

Example 3:

Input:

password = abc

Output: 10

Explanation:

Try it yourself

Solution

Invest in Yourself
Your new job is waiting. 83% of people that complete the program get a job offer. Unlock unlimited access to all content and features.
Go Pro