Question: in python please given an array of integers a, your task is to calculate the digits that occur the most number of times in the
in python please
given an array of integers a, your task is to calculate the digits that occur the most number of times in the array. return the array of these digits in ascending order. example for a = [25, 2, 3, 57, 38, 41], the output should be solution(a) = [2, 3, 5].
here are the number of times each digit appears in the array: 0 -> 0 1 -> 1 2 -> 2 3 -> 2 4 -> 1 5 -> 2 6 -> 0 7 -> 1 8 -> 1 the most number of times any number occurs in the array is 2, and the digits which appear 2 times are 2, 3 and 5. so the answer is [2, 3, 5].
input/output [execution time limit] 4 seconds (py3) [input] array.integer a an array of positive integers. guaranteed constraints: 1 a.length 103, 1 a[i] < 100. [output] array.integer the array of most frequently occurring digits, sorted in ascending order.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
