Problem · Array

Highest Rating Price Ratio

EasyMetaOA
See Meta hiring insights

You are given two arrays of positive integers containing information about some items on the market: one with their prices, and the second with their ratings from 1 to 5. Here, prices[i] corresponds to the price of the i-th item, and ratings[i] corresponds to the rating of the i-th item.

Find the item with the highest ratio of rating / price and return its index. If this ratio is equal across multiple items, return the item with the lowest index.

Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(prices.length^3) will fit within the execution time limit.

Examples
01 · Example 1
prices = [7, 5, 2, 11]
ratings = [3, 4, 1, 3]
return = 1
More Meta problems
drafts saved locally
public int solution(int[] prices, int[] ratings) {
  // write your code here
}
prices[7, 5, 2, 11]
ratings[3, 4, 1, 3]
expected1
checking account