Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer in python! 1. bestPros Thumbtack is a marketplace that matches users (regular people) to Pros (local professionals) on project basis. For example if

please answer in python!image

1. bestPros Thumbtack is a marketplace that matches users (regular people) to Pros (local professionals) on project basis. For example if a user has a house that needs painting, they will post a house-painting project on Thumbtack and Thumbtack will help them find the best Pro that's available to complete the project. 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_distance is 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: . 8th pro: (65) 4 = 4; 1st pro: (64) * 3 = 6; 2nd pro: (66) * 5 = 0; 3rd pro: (63) 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 1, pros[1] contains two elements: pros[1] [0] is the distance of the 4th Pro from the user's location and pros[1][1] is the Pro's overall rating. Guaranteed constraints: 1 s pros.lengths 104, 1 s pros[1].length= 2, 1s pros[i][j] = 100. [input] integer k The number of Pros who should be recommended to complete the user's project. Guaranteed constraints: 1sks 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.

Step by Step Solution

3.40 Rating (156 Votes )

There are 3 Steps involved in it

Step: 1

Solution ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Foundations of Financial Management

Authors: Stanley Block, Geoffrey Hirt, Bartley Danielsen, Doug Short, Michael Perretta

10th Canadian edition

1259261018, 1259261015, 978-1259024979

More Books

Students also viewed these Programming questions

Question

Solve the preceding problem for Bertrand duopolists.

Answered: 1 week ago