Skip to content

Proposal: Add New Exercise - "Most Frequent Number in an Array" #529

Open
@briz123

Description

@briz123

Description:

This exercise will challenge users to implement a function that finds the most frequent number in an array. The goal is to identify the number that appears most often in the given array, handling various edge cases like multiple numbers with the same frequency, negative numbers, and an empty array.

Why Add This?

  • Helps learners practice array manipulation and iteration.
  • Teaches how to use data structures like objects or maps to track frequencies.
  • Introduces handling of edge cases such as empty arrays and multiple most frequent numbers.

Test Cases:

mostFrequent([1, 2, 3, 4, 4, 5, 5, 5]); // ➞ 5
mostFrequent([7, 7, 8, 8, 9, 9, 9]); // ➞ 9
mostFrequent([]); // ➞ null (empty array)

If available, I would like to be assigned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions