Mean, Median, and Mode Problem Statement

Given an integer array ARR of size N, you need to compute the following three statistical measures:

  1. Mean: Implement the function mean() to calculate the mean of the array.
  2. Median: Implement the function median() to calculate the median of the array.
  3. Mode: Implement the function mode() to determine the mode of the array.

Return these measures in the specified format.

Example:

Input:
ARR = {1, 1, 2, 2, 3, 3, 4}
Output:
Mean: P Q
Median: P Q
Mode: 1
Explanation:

For the given array, the mode will be 1, as it is the smallest of all the possible modes (1, 2, and 3).

Constraints:

  • 1 <= T <= 5
  • 1 <= N <= 105
  • 1 <= ARR[i] <= 106
  • Where ARR[i] denotes the ith element of the array.
  • Time limit: 1 sec
Note:
  • Mean and Median should be returned in the form P/Q, where P and Q are coprime integers, and Q ≠ 0.
  • If multiple elements have the same highest frequency, return the smallest one as the mode.
AnswerBot
4mo

Implement functions to calculate mean, median, and mode of an integer array.

  • Calculate mean by summing all elements and dividing by total count

  • Calculate median by sorting array and finding middle eleme...read more

Help your peers!
Select
Add answer anonymously...

Mobikwik Software Developer Intern interview questions & answers

A Software Developer Intern was asked Q. Mean, Median, and Mode Problem Statement Given an integer array ARR of size N, y...read more
A Software Developer Intern was asked Q. Triplets with Given Sum Problem Given an array or list ARR consisting of N integ...read more
A Software Developer Intern was asked Q. Diamond Pattern Grid Problem Create a grid pattern of size R rows and C columns,...read more

Popular interview questions of Software Developer Intern

A Software Developer Intern was asked Q1. Mean, Median, and Mode Problem Statement Given an integer array ARR of size N, y...read more
A Software Developer Intern was asked Q2. Triplets with Given Sum Problem Given an array or list ARR consisting of N integ...read more
A Software Developer Intern was asked Q3. Diamond Pattern Grid Problem Create a grid pattern of size R rows and C columns,...read more
Mobikwik Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits