First repeated ID
Write code · Basic · §4.1 Remembering what you have seen
ids holds IDs in the order the sign-up requests came in. Complete the function solution, which goes through ids in order and returns the first ID that has already appeared earlier in the list.
If no ID is repeated, return an empty string "".
Function
solution(ids)
Constraints
- The length of
idsis from 1 to 100,000. - Each ID is a string of lowercase English letters and digits, with a length from 1 to 20.
Examples
| ids | result |
|---|---|
['kim', 'lee', 'park', 'lee', 'kim'] | 'lee' |
['a', 'b'] | '' |
Starter code
def solution(ids):
answer = ""
return answerSolve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.