Question: In JavaScript need solution Given two usernames, the degree of similarity is defined as the length of the longest prefix common to both strings. In
In JavaScript need solution

Given two usernames, the degree of similarity is defined as the length of the longest prefix common to both strings. In this challenge, you will be given a string. You must break the string to create ever shorter suffixes, then determine the similarity of the suffix to the original string. Do this for each suffix length from the length of the string to 0, and cumulate the results. As an example, consider the string 'ababa'. Compare all suffixes to the original string Suffix ababa baba aba ba Discard Similarity Length ababa aba aba abab ababa 0 So our sum is 5 +0+3+0+1+0-9 Function Description Complete the function usernameDisparity in the editor below. The function must return an integer array of the sums of the similarities for each test case. usernameDisparity has the following parameter(s): inputs inputs..inputs-an array of username strings to process Constraints 1sTs 10 The string contains only letters in the range asciila-z] Given two usernames, the degree of similarity is defined as the length of the longest prefix common to both strings. In this challenge, you will be given a string. You must break the string to create ever shorter suffixes, then determine the similarity of the suffix to the original string. Do this for each suffix length from the length of the string to 0, and cumulate the results. As an example, consider the string 'ababa'. Compare all suffixes to the original string Suffix ababa baba aba ba Discard Similarity Length ababa aba aba abab ababa 0 So our sum is 5 +0+3+0+1+0-9 Function Description Complete the function usernameDisparity in the editor below. The function must return an integer array of the sums of the similarities for each test case. usernameDisparity has the following parameter(s): inputs inputs..inputs-an array of username strings to process Constraints 1sTs 10 The string contains only letters in the range asciila-z]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
