Reported July 2026
Metaarray

Highest Rating Price Ratio

Reported by candidates from Meta's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Meta OA. Under 2s to a working solution.
Founder's read

The data structure here is just two parallel arrays, and the whole problem is reading them in lockstep. Meta reported this one in July 2026: given prices and ratings, return the index of the item with the highest rating / price ratio, ties going to the lowest index. It looks too easy to be an OA question, and that's the trap. The difficulty is in the details, not the algorithm. If you blank on the comparison logic, StealthCoder runs invisibly during the live assessment and hands you a clean solution. Most people won't need it for this one.

The problem

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.

Function
solution(prices: int[], ratings: int[]) → int

Examples
Example 1
prices = [7, 5, 2, 11]
ratings = [3, 4, 1, 3]
return = 1

Reported by candidates. Source: FastPrep

Pattern and pitfall

It's a single pass over the arrays. Track the best index so far and compare each item's ratio against the best. Use strict greater-than so ties keep the earlier index. That handles the tie rule for free. The pitfall is floating point. Dividing rating by price works for the example, but cleaner is cross-multiplication: item i beats best b if ratings[i] * prices[b] > ratings[b] * prices[i]. Prices are positive, so no division by zero and no precision drift. Check Example 1: ratios are 0.43, 0.8, 0.5, 0.27, so index 1 wins. The note about O(n^3) being acceptable is a signal that brute force is fine, but O(n) is trivial here. Don't overthink it. The real risk is a typo in the tie rule or an off-by-one on a small array. If you freeze on the setup, StealthCoder is the safety net during the live OA, but this should take five minutes.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Highest Rating Price Ratio cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Meta's OA.

Meta reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Highest Rating Price Ratio FAQ

How hard is the Highest Rating Price Ratio problem really?+

Easy. It's a linear scan with a running best. The O(n^3) allowance in the statement tells you the setters expect people to overcomplicate it. Write the simple loop, test the tie case, and move on to the harder questions.

What's the trick to this Meta OA question?+

There isn't a deep one. Track the best index, compare ratios, and use strict greater-than so the lowest index wins ties. Cross-multiplying instead of dividing avoids floating point issues entirely, which is the only mildly clever part.

Should I use division or cross-multiplication?+

Cross-multiplication is safer. Compare ratings[i] * prices[best] against ratings[best] * prices[i]. All values are positive integers, so it's exact. Division with floats usually works too, but equal ratios can occasionally compare wrong due to rounding.

What edge cases should I test before submitting?+

Test a single-item array, two items with identical ratios (expect the lower index), and the case where the best item is last. Also run Example 1 by hand: prices [7,5,2,11], ratings [3,4,1,3] should return 1.

How do I prepare for this in 48 hours?+

Don't spend long on it. Write the loop once from memory, then spend your time on the harder problems likely in the same Meta OA set. Practice reading parallel-array problems carefully, since mistakes here are about details, not algorithms.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Meta.

OA at Meta?
Invisible during screen share
Get it