A sorted list gives you information for free: equal values sit side by side, and everything smaller than an element is to its left. A solution that does not use that is a solution written for an unsorted list.
count = 0previous = Nonefor v in values:if v != previous:count += 1previous = vreturn count
Looking for a value in a sorted list you do not look at it all either. Look at the middle element: if what you want is larger, throw away the whole left half; if smaller, the right half. Each step halves what is left; a million elements take twenty steps. This is binary search.