least_frequent(items) that returns the element in list items that occurs the fewest times. Break ties by returning whichever qualifying element appears first in items. Use a dict to count occurrences.least_frequent([1, 2, 2, 3, 3, 3, 4])
1
1 and 4 both occur once; 1 appears first.
Build a count dict first.
Then scan items in order and return the first whose count equals the minimum count.