Posts

Showing posts from July, 2020

migratory birds in c++ hackerrank solution

You have been asked to help study the population of birds migrating across the continent. Each type of bird you are interested in will be identified by an integer value. Each time a particular kind of bird is spotted, its id number will be added to your array of sightings. You would like to be able to find out which type of bird is most common given a list of sightings. Your task is to print the type number of that bird and if two or more types of birds are equally common, choose the type with the smallest ID number. For example, assume your bird sightings are of types  . There are two each of types   and  , and one sighting of type  . Pick the lower of the two types seen twice: type  . Function Description Complete the  migratoryBirds  function in the editor below. It should return the lowest type number of the most frequently sighted bird. migratoryBirds has the following parameter(s): arr : an array of integers representing types of birds sighted Input Format The first line contains

Find Digits in c++ hackerrank solution

An integer   is a  divisor  of an integer   if the remainder of  . Given an integer, for each digit that makes up the integer determine whether it is a divisor. Count the number of divisors occurring within the integer. Note:  Each digit is considered to be unique, so each occurrence of the same digit should be counted (e.g. for  ,   is a divisor of   each time it occurs so the answer is  ). Function Description Complete the  findDigits  function in the editor below. It should return an integer representing the number of digits of   that are divisors of  . findDigits has the following parameter(s): n : an integer to analyze Input Format The first line is an integer,  , indicating the number of test cases.  The   subsequent lines each contain an integer,  . Constraints   Output Format For every test case, count the number of digits in   that are divisors of  . Print each answer on a new line. Sample Input 2 12 1012 Sample Output 2 3 Explanation The number   is broken into two digits,