Price Check
Updated
Problem statement
There is a shop with old-style cash registers. Rather than scanning items and pulling the price from a database, the price of each item is typed in manually. This method sometimes leads to errors. Given a list of items and their correct prices, compare the prices to those entered when each item was sold. Determine the number of errors in selling prices.
Function
priceCheck(products: String[], productPrices: float[], productSold: String[], soldPrice: float[]) → int
Complete the function priceCheck in the editor.
priceCheck has the following parameter(s):
- 1.
String[] products: eachproducts[i]is the name of an item for sale - 2.
float[] productPrices: eachproductPrices[i]is the price ofproducts[i] - 3.
String[] productSold: eachproductSold[i]is the name of a product sold - 4.
float[] soldPrice: eachsoldPrice[i]contains the sale price recorded forproductSold[i]
Returns
int: the number of sale prices that were entered incorrectly
Examples
Example 1
products = ["eggs", "milk", "cheese"]productPrices = [2.89, 3.29, 5.79]productSold = ["eggs", "eggs", "cheese", "milk"]soldPrice = [2.89, 2.99, 5.97, 3.29]return = 2
The second sale of eggs has a wrong price, as does the sale of cheese. There are 2 errors in pricing.
Constraints
1 ≤ n ≤ m1 ≤ m ≤ n|SP - productPrices[i], soldPrice[j]| ≤ 100000.00, where0 ≤ i < nand0 ≤ j < m
More Citadel interview questions
- Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
- Square Root FunctionPHONE SCREEN · Seen Oct 2026
- Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
- Spreadsheet Formula DependenciesPHONE SCREEN · Seen Oct 2026
- Possible MEX Values After One Optional IncrementOA · Seen Oct 2026
- Merge Price-Delta FeedsPHONE SCREEN · Seen Sep 2026
- Reconcile Unmatched Trades with Timestamp TolerancePHONE SCREEN · Seen Sep 2026
- Top Ten Trades by Notional ValuePHONE SCREEN · Seen Sep 2026
- Busy IntersectionOA · Seen Sep 2026
- Shortest Path in an Unweighted GraphOA · Seen Sep 2026
Similar questions at other companies
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Count Valid Square PairsAuxoAI · OA
- Two SumAmazon · OA · PHONE SCREEN
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
- Customer Signer ScreeningState Farm · OA
- Minimum Magic Stones After MergesElevenLabs · OAElevenLabs interview questions
- K Most Recent Unique Request IDsMicrosoft · OAMicrosoft interview questions
- Distinct Products After Removing One ElementHSBC · OAHSBC interview questions
Citadel interview experiences
- Citadel Securities Quant Researcher Intern Loop: 1 Experience
- Citadel Securities Research Engineer Interview: 1 Experience
- Citadel Securities SWE Intern First Round: 2 Experiences
- Citadel Securities Experienced SWE Interviews: 1 Experience
- Citadel SWE Intern Later Rounds and Superday: 13 Experiences
- Citadel SWE Intern First-Round Questions: 20 Experiences