Question 1: Price Check
Problem Statement
A shop with old-style cash registers records the price of each item manually, which can lead to errors. Given:
- A list of product names and their correct prices.
- A list of products sold and their respective entered prices.
Task: Determine the number of errors in the recorded selling prices.
Example
Input:
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]
Output:
Errors = 2
Explanation:
- The second sale of 'eggs' and the sale of 'cheese' have incorrect prices.
- Total errors = 2.
Function Description
Complete the function priceCheck(products, productPrices, productSold, soldPrice)
.
Parameters:
products[n]
: Names of items for sale.productPrices[n]
: Correct price of each item.productSold[m]
: Names of sold products.soldPrice[m]
: Recorded prices of sold products.
Returns:
int
: Number of errors in selling prices.
Constraints:
- 1 ≤ n ≤ 100000
- 1 ≤ m ≤ n
- 1.00 ≤ productPrices[i], soldPrice[i] ≤ 100000.00
Question 2: Missing Words
Problem Statement
Given two strings s
and t
:
t
is a subsequence ofs
.- Identify the words in
s
that are missing fromt
while preserving their order ins
.
Task: Return the list of missing words.
Example
Input:
s = "I am using HackerRank to improve programming"
t = "am HackerRank to improve"
Output:
['I', 'using', 'programming']
Explanation:
- The missing words in
s
but not int
are:'I', 'using', 'programming'
.
Function Description
Complete the function missingWords(s, t)
.
Parameters:
s
: A sentence of space-separated words.t
: A sentence of space-separated words.
Returns:
string[]
: List of words ins
missing fromt
, in order of occurrence.
Constraints:
- Strings
s
andt
contain only English alphabetic letters (a-z
,A-Z
), dashes (-
), and spaces. - 1 ≤ |t| ≤ |s| ≤ 1000000
- 1 ≤ length of any word in
s
ort
≤ 15
我们长期稳定承接各大科技公司如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.