Menu

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

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: 1 sk s pros. Length (output) array.integer The indices of the k best Pros to complete the users proj

Complete the function below:

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

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_distances 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 overal 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: • oth pro: (6 – 5) * 4 – 4 • 1st pro: (6 – 4) * 3 – 6 • 2nd pro: (6 – 6) * 5 – B; 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 (is) • [input] array array.integer pros An array of Pros. For each valid pros[1] contains two elements: pros(] ] is the distance of the 4th Pro from the user’s location and pros (1) is the Pro’s overall rating Guaranteed constraints: 1 s pros.lengths 184 1 spros[1]. Length – 2 1 spros[i][j] = 102 • [input) integer k The number of Pros who should be recommended to complete the user’s project. Guaranteed constraints: 1 sk s pros. Length (output) array.integer 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> 3 using namespace std; string Itrim(const string &); string rtrim(const string &); vector<string> split(const string &); * Complete the ‘bestPros’ function below. * The function is expected to return an INTEGER_ARRAY. * The function accepts following parameters: * 1. 2D_INTEGER_ARRAY pros * 2. INTEGER K 19 vector int> bestPros(vector<vector<int>> pros, int k) { 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_distances 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 overal 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: • oth pro: (6 – 5) * 4 – 4 • 1st pro: (6 – 4) * 3 – 6 • 2nd pro: (6 – 6) * 5 – B; 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 (is) • [input] array array.integer pros An array of Pros. For each valid pros[1] contains two elements: pros(] ] is the distance of the 4th Pro from the user’s location and pros (1) is the Pro’s overall rating Guaranteed constraints: 1 s pros.lengths 184 1 spros[1]. Length – 2 1 spros[i][j] = 102 • [input) integer k The number of Pros who should be recommended to complete the user’s project.
Guaranteed constraints: 1 sk s pros. Length (output) array.integer 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 3 using namespace std; string Itrim(const string &); string rtrim(const string &); vector split(const string &); * Complete the ‘bestPros’ function below. * The function is expected to return an INTEGER_ARRAY. * The function accepts following parameters: * 1. 2D_INTEGER_ARRAY pros * 2. INTEGER K 19 vector int> bestPros(vector pros, int k) { 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