Range Distinctness Check

Asked at GoogleOnsite

Reported by the problem's creator, not verified

You are given an integer array nums that never changes. RangeUnique(nums) builds a checker once, and each query asks about a range of positions counted from 0, with both ends included.

Examples

  1. Example 1

    Input: init = [[3,1,4,1,5,9,2,6]], operations = [["is_unique",[0,7]],["is_unique",[0,2]],["is_unique",[1,3]],["is_unique",[2,5]],["is_unique",[3,3]],["is_unique",[1,4]],["is_unique",[3,7]]]

    Output: [false,true,false,true,true,false,true]

    Explanation: The value 1 sits at indices 1 and 3. Any range containing both fails, such as (0, 7), (1, 3) and (1, 4); (0, 2), (2, 5), (3, 3) and (3, 7) do not.

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.