Looking for a Matching Score
FastPrep has an extensive customer database, which contains a vast number of users. To maintain uniqueness and prevent customers from having very similar usernames, FastPrep's DB Management experts have come up with a solution. They have decided to define what is known as a "F-match" score between two usernames.
Now let's consider two users, each with their respective User IDs: user1ID, which has a length of x, and user2ID, which has a length of y. Each User ID is represented as a string consisting solely of lowercase English letters.
To determine how closely related these usernames are, the F-match score is introduced. The F-match score of user1ID with respect to user2ID is defined as the maximum number of distinct indices i such that the string formed by concatenating characters user1ID[i], user2ID[i + z], ... , user1ID[i + (y - 1) × z] can be rearranged to exactly match user2ID.
This condition holds true under the following constraints:
Given two strings that represent user IDs, the goal is to determine the f-match score between them. This involves analyzing how closely related the two user IDs are by applying the matching criteria and finding the best possible match based on the given conditions.
Complete the function lookingForAMatchingScore in the editor.
findScore has the following parameters:
String user1ID: the username of 1st userString user2ID: the username of 2nd userint z: the interval at which the characters fromuserID1are concatenated
Returns
int: the score of user1ID with respect to user2ID.
Forever thankful for spike! - on 02-03-25
1Example 1
Constraints
Limits and guarantees your solution can rely on.
1 ≤ |user2ID| ≤ |user2ID| ≤ 10^61 ≤ z ≤ 10^6- User strings
user1IDanduser2IDonly contain lowercase Latin letters.