Your question is Implementing a Basic Search. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Taobao may receive product identifiers in an unsorted sequence from a batch request. Implement a linear search that returns the index of the first occurrence of a target product ID.
Write find_product_id(product_ids, target).
product_ids is a list of integers.target is an integer product ID.target.-1 if target does not appear in the list.Because the list is not guaranteed to be sorted, inspect elements from left to right and stop as soon as the target is found.
def find_product_id(product_ids, target):