Fix the default list
EasyWrite a function that adds
item to items if it isn't already there, then returns the list.If the caller doesn't pass
items, start from a new empty list.For example
add_unique('b', ['a'])
should return
['a', 'b'].And
add_unique('x')
should return
['x'].The starter code is almost right. Run it more than once.
Try it first
Solution
7 Essential DSA in the AI era Coding Interview Problems
Master DSA in the AI era by trying the coding challenges below.
- 1.Count occurrencesEasy
- 2.Fix the default listEasy
- 3.Move zeroesEasy
- 4.Is subsequenceEasy
- 5.First unique characterEasy
- 6.Group anagramsMedium
- 7.Climb stairsEasy
