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]
Product | Price | ||
---|---|---|---|
Actual | Expected | Error | |
eggs | 2.89 | 2.89 | |
eggs | 2.99 | 2.89 | 1 |
cheese | 5.97 | 5.79 | 1 |
milk | 3.29 | 3.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]
: eachproducts[i]
is the name of an item for salestring productPrices[n]
: eachproductPrices[i]
is the price ofproducts[i]
string productSold[m]
: eachproductSold[j]
is the name of a product soldfloat soldPrice[m]
: eachsoldPrice[j]
contains the sale price recorded forproductSold[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
where0 ≤ i < n
and0 ≤ 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.
