Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6454 |

@blackshadows | 6380 |

@mb1973 | 5718 |

@Quandray | 5245 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5046 |

@sanjay05 | 3762 |

@kirtidee18 | 3709 |

@mantu_singh | 3556 |

@marius_valentin_dragoi | 3523 |

@sushant_a | 3459 |

Complete Leaderboard | |

Handle | Score |

@cfwong8 | 1285 |

@gurshehzadsingh | 1052 |

@pritsahkar2000 | 812 |

@satyamchhatrala | 806 |

@nithinreddy3210 | 801 |

@iib2019024 | 745 |

@mohanreddy8847 | 704 |

@iamchaitanyahegde | 662 |

@shafeeq3543 | 651 |

@workit | 646 |

@AkashLahoty | 642 |

Complete Leaderboard |

Given an array nums** **of n elements and q queries . Each query consists of two integers l and r . You task is to find the number of elements of nums[] in range [l,r] which occur atleast k times.

**Example 1:**

**Input: **nums = {1,1,2,1,3}, Queries = {{1,5},
{2,4}}, k = 1
**Output: **{3,2}
**Explanation: **For the 1st query, from l=1 to r=5
1, 2 and 3 have the frequency atleast 1.
For the second query, from l=2 to r=4, 1 and 2 have
the frequency atleast 1.

**Your Task:**

Your task is to complete the function **solveQueries() **which takes nums, Queries and k as input parameter and returns a list containg the answer for each query.

**Expected Time Complexity: **O(n*sqrt(n)*log(n))

**Expected Space Compelxity: **O(n)

**Constraints:**

1 <= n, no of Queries, k <= 10^{4}

1 <= nums[i] <= 10^{3}

1 <= Queries[i][0] <= Queries[i][1] <= n

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

YesLoading...

Interesting Queries

...