Hashtags used only once
Write code · Basic · §4.3 Counting occurrences
tags holds the hashtags that one person has used in their posts so far, in the order they were used. The # sign in front of each hashtag is left out.
Complete the function solution, which returns a list of the hashtags that were used exactly once, in the order they appear in tags. If there is no such hashtag, return an empty list.
Function
solution(tags)
Constraints
- The length of
tagsis from 1 to 100,000. - Each hashtag is a string of lowercase English letters and digits, with a length from 1 to 20.
Examples
| tags | result |
|---|---|
['daily', 'cafe', 'daily', 'ootd'] | ['cafe', 'ootd'] |
['travel', 'travel'] | [] |
Starter code
def solution(tags):
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.