less than 1 minute read

Given a list of sorted integers nums return the number of unique integers in the list.

Contraints

  • n ≤ 1,000,000 where n is the length of nums

Notes

  • \(\mathcal{O}(n)$` is accepted but `$\mathcal{O}(k\log{}n)\) is encouraged.

https://binarysearch.com/problems/Unique-Integers-in-Sorted-List

Examples

Example 1

Input

  • nums = [2, 2, 2, 3, 4, 6, 6]

Output

  • answer = 4

Explanation

The unique numbers are [2, 3, 4, 6]

Solution

Categories:

Updated:

Leave a comment