Looking for a Matching Score
Learn this problemProblem statement
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.
Function
lookingForAMatchingScore(user1ID: String, user2ID: String, z: int) → int
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
Examples
Example 1
user1ID = "acaccaa"user2ID = "aac"z = 2return = 2Constraints
1 ≤ |user2ID| ≤ |user2ID| ≤ 10^61 ≤ z ≤ 10^6- User strings
user1IDanduser2IDonly contain lowercase Latin letters.
More Amazon problems
- Resolve Task DependenciesONSITE INTERVIEW · Seen Jul 2026
- Shortest Distance on a Circular Bus RouteOA · Seen Jul 2026
- Longest Increasing Subsequence With Bounded Adjacent DifferenceONSITE INTERVIEW · Seen Jul 2026
- Search in a Rotated Sorted ArrayONSITE INTERVIEW · Seen Jul 2026
- Sliding Window MaximumONSITE INTERVIEW · Seen Jul 2026
- Merge IntervalsOA · Seen Jul 2026
- Sort Bug Report FrequenciesOA · Seen Jul 2026
- Drone Delivery RouteOA · Seen Jul 2026