Menu

Thumbtack User Creates New Project Recommend Best Pros Job Based Metric Called Pro Matchin Q43805435

When a Thumbtack user creates a new project, we recommend the best Pros for the job based on a metric called the Pro Matching

Guaranteed constraints: 1sks pros.length. [output] array.integer o The indices of the k best Pros to complete the users proj

Complete the function below:

1 v #include <bits/stdc++.h> using namespace std; 4 string ltrim (const string &); string rtrim(const string &); vector<strin

Code in C++

When a Thumbtack user creates a new project, we recommend the best Pros for the job based on a metric called the Pro Matching Score (PMS). This score is calculated using two factors: the distance the Pro would have to travel to the job, and the Pro’s average rating. More specifically, PMS is defined as (max_distance – distance) * rating where max_distanceis the maximal distance that any Pro has from the given user. Naturally, a higher PMS means the Pro is a better match for the project. You have an array that represents the Pros who are available to complete a new project for a user, where each element of the array is a [distance, rating] tuple. distance is the distance of the Pro from the user’s project location, and rating is their overall rating. Given the array pros for a specific project, determine the kPros who are best suited to complete it, based on their Pro Matching Score. Return a list of the indices (0-based) at which these Pros appeared in the original pros array. sorted by their PMS score. In the case of a PMS tie, the Pro with the smaller index goes first. Example For pros = [[5, 4], [4, 3], [6, 5], [3, 5]] and k = 2, the output should be bestPros (pros, k) = [3, 1]. The PMSS of the Pros are: • sth pro: (6 – 5) * 4 – 4; • 1st pro: (6 – 4) * 3 – 6; • 2nd pro: (6 – 6) * 5 – 0; • 3rd pro: (6 – 3) * 5 – 15. The output is [3, 1] since the Pros at indices 1 and 3 have the highest scores. Since pro[3] has a higher PMS than pro [1], index 3 appears first in the array. Input/Output • [execution time limit] 4 seconds (js) • [input] array.array.integer pros An array of Pros. For each valid 1, pros(4] contains two elements: pros[i] [0] is the distance of the i th Pro from the user’s location and pros(i] [1] is the Pro’s overall rating. Guaranteed constraints: 1s pros. length s 184 1s pros[i).length – 2. 1s pros[i)) s 100. • [input] integer k The number of Pros who should be recommended to complete the user’s project. C……. ……in Guaranteed constraints: 1sks pros.length. [output] array.integer o The indices of the k best Pros to complete the user’s project from the original pros array, sorted by their Pro Matching Score. In the case of a PMS tie, the Pro with the smaller index goes first. If there are fewer than k suitable Pros, return all of them. 1 v #include <bits/stdc++.h> using namespace std; 4 string ltrim (const string &); string rtrim(const string &); vector<string> split(const string &); /* * Complete the ‘bestPros’ function below. 11 12 * The function is expected to return an INTEGER_ARRAY. * The function accepts following parameters: 1. 20_INTEGER_ARRAY pros * 2. INTEGER k */ 13 14 15 16 17 18 vector<int> bestPros (vector<vector<int>> pros, int k) { 19 20 21 22 > int main() Show transcribed image text When a Thumbtack user creates a new project, we recommend the best Pros for the job based on a metric called the Pro Matching Score (PMS). This score is calculated using two factors: the distance the Pro would have to travel to the job, and the Pro’s average rating. More specifically, PMS is defined as (max_distance – distance) * rating where max_distanceis the maximal distance that any Pro has from the given user. Naturally, a higher PMS means the Pro is a better match for the project. You have an array that represents the Pros who are available to complete a new project for a user, where each element of the array is a [distance, rating] tuple. distance is the distance of the Pro from the user’s project location, and rating is their overall rating. Given the array pros for a specific project, determine the kPros who are best suited to complete it, based on their Pro Matching Score. Return a list of the indices (0-based) at which these Pros appeared in the original pros array. sorted by their PMS score. In the case of a PMS tie, the Pro with the smaller index goes first. Example For pros = [[5, 4], [4, 3], [6, 5], [3, 5]] and k = 2, the output should be bestPros (pros, k) = [3, 1]. The PMSS of the Pros are: • sth pro: (6 – 5) * 4 – 4; • 1st pro: (6 – 4) * 3 – 6; • 2nd pro: (6 – 6) * 5 – 0; • 3rd pro: (6 – 3) * 5 – 15. The output is [3, 1] since the Pros at indices 1 and 3 have the highest scores. Since pro[3] has a higher PMS than pro [1], index 3 appears first in the array. Input/Output • [execution time limit] 4 seconds (js) • [input] array.array.integer pros An array of Pros. For each valid 1, pros(4] contains two elements: pros[i] [0] is the distance of the i th Pro from the user’s location and pros(i] [1] is the Pro’s overall rating. Guaranteed constraints: 1s pros. length s 184 1s pros[i).length – 2. 1s pros[i)) s 100. • [input] integer k The number of Pros who should be recommended to complete the user’s project. C……. ……in
Guaranteed constraints: 1sks pros.length. [output] array.integer o The indices of the k best Pros to complete the user’s project from the original pros array, sorted by their Pro Matching Score. In the case of a PMS tie, the Pro with the smaller index goes first. If there are fewer than k suitable Pros, return all of them.
1 v #include using namespace std; 4 string ltrim (const string &); string rtrim(const string &); vector split(const string &); /* * Complete the ‘bestPros’ function below. 11 12 * The function is expected to return an INTEGER_ARRAY. * The function accepts following parameters: 1. 20_INTEGER_ARRAY pros * 2. INTEGER k */ 13 14 15 16 17 18 vector bestPros (vector pros, int k) { 19 20 21 22 > int main()

Expert Answer


Answer to When a Thumbtack user creates a new project, we recommend the best Pros for the job based on a metric called the Pro Mat…

OR