H-Index Problem

Problem Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return compute the researcher’s h-index. According to the definition of h-index on Wikipedia: A scientist has an index h if h of their n papers have at least h citations each, and the other n − h papers have no more than h citations each. If there are several possible values for h, the maximum one is taken as the h-index. ...

Check if Intervals Overlap

Problem Given a set of intervals, find out if any two intervals overlap. Example: Intervals: [ [1,4], [2,5], [7,9] ] Output: true Explanation: Intervals [1,4] and [2,5] overlap Solution Method 1 - Sorting Let’s take the example of two intervals (‘a’ and ‘b’) such that a.start <= b.start. There are three possible scenarios: ...

Frequency of the Most Frequent Element

Problem The frequency of an element is the number of times it occurs in an array. You are given an integer array nums and an integer k. In one operation, you can choose an index of nums and increment the element at that index by 1. Return the maximum possible frequency of an element after performing at most k operations. Examples Example 1: Input: nums = [1,2,4], k = 5 Output: 3 Explanation: Increment the first element three times and the second element two times to make nums = [4,4,4]. 4 has a frequency of 3. ...

Maximum Intervals Overlap Count

Problem Find maximum intervals overlap. OR There is number of elephants time span given, here time span means, year of birth to year of death. You have to calculate the period where maximum number of elephants are alive. OR Consider a big party where a log register for guest’s entry and exit times is maintained. Find the time at which there are maximum guests in the party. Note that entries in register are not in any order. ...

Count frequency of target element in sorted array

Problem Given a sorted array of integers and a target element. Find the number of occurrences of the target in the array. You must write an algorithm with O(log n) runtime complexity. Examples Example 1: Input: nums = [1, 1, 2, 2, 2, 2, 3], target = 2 Output: 4 Explanation: 2 appears four times in the array ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy