Data Structures & AlgorithmsVery hardTCS NQT · Infosys
How many distinct values in [1, 1, 2, 2, 2, 3, 4, 4] occur more than one third of the time (count times 3 greater than n)?
- A. 2
- B. 3
- C. 1
- D. 5
Correct answer: C. 1
With n = 8, a value qualifies when its count exceeds 8/3, that is at least 3. Only 2 occurs three times.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- How many substrings of the string aabbaabb have an equal number of letters a and b?
- What is the length of the longest prefix of abacaba that is a palindrome?
- What is the sum of floor(i / 2) for i = 1 to 10?
- What is the smallest positive integer that has exactly 6 positive divisors?
- How many integers n in [1, 100] have both n and n + 2 prime?
- What is gcd(2^12 - 1, 2^8 - 1)?