Given an array with length n , find highest value which occurs same number of times within the array. [3,8,3,2,1,3,2] 3 occurs 3 times output=3. [4,6,7,6,7,5,4,2,4,9,4,1,9] 4 occurs 3 times output=4
AnswerBot
1y
Find the highest value that occurs the same number of times within an array.
Iterate through the array and count the occurrences of each value.
Store the counts in a dictionary or hash map.
Find the maxi...read more
Pritam Chowdhury
2y
private static int returnMax(int[] arr, int n){ HashMap<Integer, Integer> newHash = new HashMap<>(); int max = 0; for(int a : arr){ newHash.put(a,newHash.getOrDefault(a,0)+1); } for(Map.Entry<Integer,...read more
Help your peers!
Add answer anonymously...
Top Morgan Stanley Software Developer interview questions & answers
Popular interview questions of Software Developer
Top HR questions asked in Morgan Stanley Software Developer
>
Morgan Stanley Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app