Your question is Duplicate Detection in List. 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.
Uber Eats can receive a list of item identifiers from a cart or order request. Implement a function that returns True if a specific target item appears more than once in the list, and False otherwise.
items, a list of values, and target, the value to search for.target occurs at least two times in items.Example 1
Input: items = ["burger", "fries", "burger"], target = "burger"
Output: True
The target appears at indices 0 and 2.
Example 2
Input: items = ["coffee", "tea", "juice"], target = "tea"
Output: False
The target appears only once.
Example 3
Input: items = ["salad", "salad", "salad"], target = "salad"
Output: True
Two matching occurrences are enough, so the function can stop early.
0 <= len(items) <= 10^5target is a hashable Python value.target.def appears_more_than_once(items, target):