Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 692679
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:40:32+00:00 2026-05-14T02:40:32+00:00

How to find the integer occurring maximum number of times (mode) in an unsorted

  • 0

How to find the integer occurring maximum number of times (mode) in an unsorted array of integers?

One O(nlogn) approach I could think of is to sort. Is there any other better approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:40:32+00:00Added an answer on May 14, 2026 at 2:40 am

    I think you want to find out element that has most occurences in the array –
    if you don’t care about memory, traverse the array once, increase count of each element in the hashtable. Then find the one with highest count. You’d need one traverse of array and one of the hashtable.

    so in pseudocode:

    hashtable hash;
    foreach(element in array){
      if(!hash.contains(element))
        hash[element] = 1;
      else 
        hash[element]++;
    }
    
    int max = 0;
    max_element;
    foreach(element in hash)
       if(hash[element] > max)
       {
         max_element = element;
         max = hash[element];
       }
    
    //max_element contains the maximum occuring one.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given an array of N integer such that only one integer is repeated. Find
Possible Duplicate: Find integer not occurring twice in an array Accenture interview question -
Given an integer array, i need to find which number occurred most number of
I'm trying to find an integer number of days between two dates in Oracle
How to find the size of an integer array in C. Any method available
Given is an array of integers. Each number in the array occurs an ODD
Given a list of integers, how can I best find an integer that is
I couldn`t find the number on limit for the Integer in Mongomapper. May it
I have to store integer values which are mapped to other integers. One way
Given a string such as: a:2:{i:0;s:1:1;i:1;s:1:2;} I want to find every integer within quotes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.