Programming Exercises

Write a component that finds the most common number in a hardcoded array and displays it.

Hard

Problem Statement

Write a component that finds the most common number in a hardcoded array and displays it.

Sample Input

[1, 2, 2, 3, 3, 3, 4]

Sample Output

Most Common Number: 3

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
import React from "react"; const MostCommonNumber = () => { return ( <div> {/* Display the most common number */} </div> ); }; export default MostCommonNumber;
Log in or sign up to run or submit your code.Log inSign up
Input
[1, 2, 2, 3, 3, 3, 4]
Expected Output
Most Common Number: 3