2936. Number of Equal Numbers Blocks
You are given a 0-indexed array of integers,
nums. The following property holds fornums:
- All occurrences of a value are adjacent. In other words, if there are two indices
i < jsuch thatnums[i] == nums[j], then for every indexkthati < k < j,nums[k] == nums[i].Since
numsis a very large array, you are given an instance of the classBigArraywhich has the following functions:
int at(long long index): Returns the value ofnums[i].void size(): Returnsnums.length.Let’s partition the array into maximal blocks such that each block contains equal values. Return the number of these blocks.
Note that if you want to test your solution using a custom test, behavior for tests with
nums.length > 10is undefined.
1 | /** |