well , I dont understand , why this input is valid, coz in the roblem statement they wrote ,mf wrote:This one maybe is a bit tricky.Output: 3
Code: Select all
7 1 1 2 2 2 2 2 3 3 5 0
If it didn't help, you could write a simple brute force solution and cross-check its output with your solution on random cases.
here the value of j is greater than an which is 3.The following q lines contain one query each, consisting of two integers i and j (1 ≤ i ≤ j ≤ n), which indicate the boundary indices for the query.