1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mrac [35]
1 year ago
8

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.
Computers and Technology
1 answer:
Annette [7]1 year ago
3 0

Answer:

I hope this should be helpful

Explanation:

In Javascript

function solution(numbers) {

   let hashmap = {};

   let ans = [];

   for (let i = 0; i < numbers.length; i++) {

     // check wether it double or single digit

     if (hasOneDigit(numbers[i])) {

       // check if it exists in hashmap

       // if exist add number of occurence

       // check if the occurence is greater than 2

       // add  if > 2 to the answer list

       if (numbers[i] in hashmap) {

         hashmap[numbers[i]] = hashmap[numbers[i]] + 1;

 

         if (hashmap[numbers[i]] = 2 && !ans.includes(numbers[i])) {

           // max_freq = hashmap[numbers[i]]

           ans.push(numbers[i]);

         }

         // else if (max_freq == hashmap[numbers[i]])

         //     ans = min(ans, numbers[i])

       } else {

         hashmap[numbers[i]] = 1;

       }

     } else {

       // change number to string

       number = numbers[i].toString();

       // loop to iterate every single element

       for (let j = 0; j < number.length; j += 1) {

 

         if (+number.charAt(j) in hashmap) {

           hashmap[+number.charAt(j)] = hashmap[+number.charAt(j)] + 1;

 

           if (hashmap[+number.charAt(j)] = 2 && !ans.includes(+number.charAt(j))) {

     

             ans.push(+number.charAt(j));

           }

       

         } else {

             hashmap[+number.charAt(j)] = 1

         }

       }

     }

   }

     return ans.sort();

 }

 

 function hasOneDigit(val) {

   return String(Math.abs(val)).charAt(0) == val;

 }

 console.log(solution([2, 1,42,44, 2, 3,32,7777, 3 , -1]));

 

You might be interested in
When installing the latest version of Internet Explorer, a dialogue box pops up with a box checked telling you that Bing will be
meriva

Answer:

B) opt-out identify

Explanation:

To opt-out means refusing to or avoiding to accept unsolicited refers to  products or service information. In this caseyou are refusing to accept Bing as your default search provider

8 0
2 years ago
What is a location where the embedded multimedia terminal is connected to both outside and inside wiring​
anygoal [31]

Answer:

The answer to this question is "The main closet or telecommunications closet".

Explanation:

A multimedia terminal or multimedia terminal adapter (MTA) is also known as a Landline modem that operates just like a wireless router, but in terms of high-speed Internet, an MTA can provide Home Phone service only.

  • In the case of a significant power failure, MTAs have only a backup battery that will fuel the MTA for many hours.
  • This device is used to connect to a main or telecommunications closet.

4 0
3 years ago
Five programs are currently being run in a computer. Program 1 is using 10 GiB of RAM, program 2 is using 5 GiB of RAM, program
muminat

Virtual memory could be used to allow program 5 to access RAM without any of the data from the other four programs being lost because it is one that tend to allows the system to give all of the process its own memory space that is said to be  isolated from the other processes.

<h3>How is virtual memory used instead of RAM?</h3>

A system is known to make use of a virtual memory and this is one that tend to make use of a section of the hard drive to act like the RAM.

With the use of virtual memory, a system can be able to load bigger or a lot of programs running at the same time, and this is one that tends to hep one to work as if it has more space, without having to buy more RAM.

Therefore, Virtual memory could be used to allow program 5 to access RAM without any of the data from the other four programs being lost because it is one that tend to allows the system to give all of the process its own memory space that is said to be  isolated from the other processes.

Learn more about virtual memory from

brainly.com/question/13088640

#SPJ1

6 0
1 year ago
What should be done to make sure the AutoSum feature will use the correct range?
morpeh [17]

Answer:

a

Explanation:

3 0
2 years ago
To use an outline for writing a formal business document, what should you
nydimaria [60]

Answer: D. enter each major point from the outline on a separate line

6 0
3 years ago
Other questions:
  • Match the items.
    15·1 answer
  • Where is authorization management app on tablet?
    7·1 answer
  • In a relational database, the three basic operations used to develop useful sets of data are:
    10·1 answer
  • Who can help me with 50 varables on codeskulptor​
    8·1 answer
  • Machine-to-machine (M2M) technology enables sensor-embedded products to share reliable real-time data ________.Select one:a. ove
    14·1 answer
  • Write a method called classAttendence() that creates a 10-by-10 two-dimensional array and asks for user input to populate it wit
    14·1 answer
  • Examples of domain names and usernames<br><br><br><br>​
    11·1 answer
  • Match the characteristics to the mobile operating system that it describes.
    11·1 answer
  • How can i fix a all white phone screen
    11·2 answers
  • Describe advantages and disadvantages for microprocessor controlled devices in the household.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!