Find Network Calls (Also For Amazon UK :)
Learn this problemProblem statement
A digital commerce platform is conducting an experiment on the number of customer feedback entries associated with each item in its catalog.
You are provided with an array feedback of size n, where feedback[i] denotes the current number of feedback entries for the i-th item. The platform offers API endpoints that allow modifying these counts by either increasing or decreasing them by one per call.
Given an integer array targetCounts of size q, your task is to determine the number of API calls required to adjust the feedback count of every item in feedback so that all items match each value in targetCounts.
The objective is to return an array of size q, where the i-th element represents the total number of API calls necessary to align all feedback counts with targetCounts[i].
Function
findNetworkCalls(feedback: int[], targetCounts: int[]) → long[]
Complete the function findNetworkCalls in the editor below.
findNetworkCalls has the following parameters:
int feedback[n]: the initial count of reviews of each productint targetCounts[q]: the equal count of reviews
Returns
long[]: an array where each element denotes the total API calls needed to align all feedback counts to the corresponding value in targetCounts
🌷 ᡣ𐭩જ⁀➴All Credit goes to interested_max ༊·˚
Examples
Example 1
feedback = [4, 6, 5, 2, 1]targetCounts = [3]return = [10, 20]
Example 2
feedback = [3, 6, 6]targetCounts = [5, 6]return = [4, 3]Constraints
feedback[i] ≤ 10^6targetCounts[i] ≤ 10^6More Amazon problems
- Secure Maximum DeliveriesOA · Seen Jul 2026
- Find Median from Data StreamONSITE INTERVIEW · Seen Jul 2026
- Handwritten SigmoidPHONE SCREEN · Seen Jul 2026
- Handwritten SoftmaxPHONE SCREEN · Seen Jul 2026
- Koko Eating BananasONSITE INTERVIEW · Seen Jul 2026
- Loyal Customers Across Two DaysONSITE INTERVIEW · Seen Jul 2026
- Maximum System Memory CapacityOA · Seen Jul 2026
- Package Delivery SystemOA · Seen Jul 2026