FastPrepElements Occurring More Than n/3 Times
Problems/Elements Occurring More Than n/3 Times

Elements Occurring More Than n/3 Times

Mygate logoMygate● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Mygate phone screen for a full-time role. The report asks for array values that occur more than n/3 times. It calls them digits and leaves out the order and the limits. Here we count whole integers and return the distinct qualifying values in sorted order.

Our version is about 90% the same as the reported question.

Given an integer array nums of length n, return every distinct value whose frequency is strictly greater than n / 3.

Return qualifying values in increasing numerical order. Frequency counts occurrences of the whole integer value, rather than its individual decimal digits. Return an empty array if no value qualifies.

Function

majorityOverThird(nums: int[]) → int[]

Examples

Example 1

nums = [3,2,3]return = [3]

The value 3 occurs twice, strictly more than 3 / 3 = 1.

Example 2

nums = [1,2,1,2,1,2,3]return = [1,2]

Both 1 and 2 occur three times, more than 7 / 3.

Example 3

nums = [1,2,3,4]return = []

No frequency exceeds 4 / 3.

Constraints

  • 0 <= nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9
  • For integer frequencies, the threshold is equivalent to frequency > floor(n / 3).

More Mygate Phone Screen questions

  • Employees Earning More Than Their ManagerPHONE SCREEN · Seen Sep 2026
  • Maximum Subarray SumPHONE SCREEN · Seen Sep 2026
  • Reverse a Linked ListPHONE SCREEN · Seen Sep 2026
  • Users Active in Both January and FebruaryPHONE SCREEN · Seen Sep 2026
  • Frog Jump: Minimum EnergyPHONE SCREEN · Seen Jan 2025
  • Left View of a Binary TreePHONE SCREEN · Seen Jan 2025
  • Two SumPHONE SCREEN · Seen Aug 2024
  • Minimum in a Rotated Sorted ArrayPHONE SCREEN · Seen Jul 2024
  • Minimum Subarray SumPHONE SCREEN · Seen Sep 2023
  • Remove the Nth Node from the EndPHONE SCREEN · Seen Sep 2023

Similar questions at other companies

  • Mutual-Friend RecommendationsMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Merchant Matching, Parts 1–2: Shared Fields and Weighted ThresholdsStripe · PHONE SCREENStripe interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN
  • Insert Delete GetRandom O(1)Charta Health · PHONE SCREENCharta Health interview questions
  • Longest Consecutive SequenceKotak Mahindra Bank · PHONE SCREENKotak Mahindra Bank interview questions
  • Longest Consecutive SequenceJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
  • Logger Rate Limiter with Every-Arrival HistoryGoogle · PHONE SCREENGoogle interview questions
  • Propagating Fraud DetectorAffirm · PHONE SCREEN · ONSITE INTERVIEWAffirm interview questions
  • Top K Frequent Elements with a Recency TiebreakSwiggy · PHONE SCREEN
All Mygate interview questionsSee Mygate hiring insights
Saved
class Solution {
    public int[] majorityOverThird(int[] nums) {
        // write your code here
    }
}
Checking account…