1. Character Reprogramming
A control device has 4 buttons that can be used to move a character around a screen in 4 directions: Up (U), Down (D), Left (L), and Right (R). The movement needs to be optimized by deleting unnecessary instructions while maintaining the same destination. Given the original set of instructions, what is the maximum number of instructions that can be deleted and still have the character reach the destination?
Note: The instructions that are deleted do not need to be contiguous.
Example:
- Input:
s = 'URDR'
- Explanation: The character starts at the initial position and ends 2 units to the right. By deleting
U
andD
, the remaining instructionsR
andR
still result in the same destination. - Output:
2
2. Duplicated Products
You are given a complex list of n
products, each with a name
, price
, and weight
. Find out how many duplicate products are present within the list. Duplicate products contain identical parameters for all fields in the list (i.e., name
, price
, and weight
).
Example:
- Input:
n = 5 name = [ball, bat, glove, glove, glove] price = [2, 3, 1, 2, 1] weight = [2, 5, 1, 1, 1]
- Explanation: There are two duplicate products:
- The first duplicate is
glove
withprice = 1
andweight = 1
. - The second duplicate is also
glove
withprice = 1
andweight = 1
.
- The first duplicate is
- Output:
2
CSOAhelp长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
CSOAhelp 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.