Report
Problem
For n elements, find all elements from a list provided that shows more than n/4 times.
Input
Java types (String, numbers and char) as a list
Output
Elements found or not
Analysis
There was a group discussion about how represent elements the question provided. How to build a collection to store all different factors and visit easily? HashMap is one solution to that problem.
Solution
To build a list {"Student",‘A’,5,'A','A',5,5,"Student",'A',5,"Human",100}.
There are three types in the list, String, char and number. Put all the elements into a HashMap, and give them keys individually. Then, build a iterator for traversing all the HashMap values. When it found a match one, a counter will plus one.
After the iterator finished, take the result of the counter, compare it with n/4 times, if more than it, then the element is the right one which will be collected into a HashSet (because of the property of a set: when put the same elements into a set, it will not exist more than one time).
Following this, there is an outside loop to go through all the elements of the list from one to another. After the outside loop finished, print the HashSet which contains all correct and distinct answers.
Result
n = 12
n / 4 = 3
Result is {5, A}