[Citadel] OA 2025 Start – 06 Feb (Generic)

3. Price Check - RPA

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.

Example

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]  
ProductPrice
ActualExpectedError
eggs2.892.89
eggs2.992.891
cheese5.975.791
milk3.293.29

The second sale of eggs has a wrong price, as does the sale of cheese. There are 2 errors in pricing.

Function Description

Complete the function priceCheck in the editor below.

priceCheck has the following parameters:

  • string products[n]: each products[i] is the name of an item for sale
  • string productPrices[n]: each productPrices[i] is the price of products[i]
  • string productSold[m]: each productSold[j] is the name of a product sold
  • float soldPrice[m]: each soldPrice[j] contains the sale price recorded for productSold[j]

Returns:

  • int: the number of sale prices that were entered incorrectly

Constraints

  • 1 ≤ n ≤ 10^5
  • 1 ≤ m ≤ n
  • 1.00 ≤ productPrices[i], soldPrice[i] ≤ 100000.00 where 0 ≤ i < n and 0 ≤ j < m

我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。

We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.

Leave a Reply

Your email address will not be published. Required fields are marked *