Puzzle CornerSign In
HomeFeedbackBlogResourcesAbout
Starred
Add Question
All (696)
coding (266)
c++ (157)
algorithms (151)
puzzle (134)
CS Fundamentals (83)
oop (55)
arrays (45)
internet (40)
string (34)
math (31)
databases (28)
system (26)
probability (26)
networking (25)
linkedlist (24)
binarytrees (24)
tree (22)
bit manipulation (19)
sorting (11)
stack (10)
bst (9)
java (8)
xml (8)
sql (7)
next in series (7)
traversal (6)
graph (4)
debugging (4)
lateral thinking (4)
palindrome (4)
mysql (4)
prime (4)
general (4)
unix (3)
CGI (3)
duplication (3)
threading (3)
random (3)
search (3)
fibonacci (3)
encryption (3)
joins (3)
hash (3)
queue (3)
asm (3)
design patterns (2)
Sum of the most common element in an array[2008-09-08 19:39:30]
Find the sum of the most common element in an array. Example: A[]={12,23,24,89,78,76,24} OutPut:48
Author:premTags: algorithms | coding | arrays | c++1 Comment


Answers:


answer[2008-11-03 07:12:12]
1. Create hashtable\r\n2. for every element in the array\r\n3. if element is present in hash table\r\n4. increment its value by 1\r\n5. else create an entry in the hash table & initialize its value with 1\r\n7. end for\r\n8. find the largest value in hash table & answer = value * key.\r\n
Author:Anon




Created by Premchand Jayamohan