Problem ยท Math
Calculate Mean and Mode
Learn this problemProblem statement
Given an integer inputNum, representing the number of elements in the set (N).
The next line consists of N space-separated integers representing the elements of the given set.
Print K space-separated integers where the first number is the mean of the input numbers and the second number is the mode (where K=2).
Note
If mean calculated is in decimal, print its floor value (Floor is the greatest integer less than or equal to that number: floor[2.4] = 2).
Function
calculateMeanAndMode(inputNums: int[]) โ int[]Examples
Example 1
inputNums = [1, 2, 7, 3, 2]return = [3, 2]The mean for the given set of numbers is 3 (1+2+7+3+2 = 15, 15/2=3). The mode is the most frequently occurring number which is 2.
So, the output is 3, 2.
Constraints
๐๐More Cisco problems
- Collect CoinsSeen Jun 2025
- FizzBuzz ProblemSeen May 2025
- Find Largest Sum Contiguous SubarraySeen May 2025
- Find Largest Sum of Continuous SequenceSeen May 2025
- Find Palindrome Sub-stringSeen May 2025
- Count Numbers with Digit SumSeen Mar 2025
- Maximum Chocolates from Jars (L.C. 198 :)Seen Mar 2025
- Find Elements Largest in Row Smallest in ColumnSeen Mar 2025