title-img


Between Two Sets

There will be two arrays of integers. Determine all integers that satisfy the following two conditions: The elements of the first array are all factors of the integer being considered The integer being considered is a factor of all elements of the second array These numbers are referred to as being between the two arrays. Determine how many such numbers exist. Example a=[2,4] b=[24,36] There are two numbers between the arrays: 6 and 12. 6%2=0, 6%6=0, 24%6=0 and 36%6=0 for the f

View Solution →

Breaking the Records

Maria plays college basketball and wants to go pro. Each season she maintains a record of her play. She tabulates the number of times she breaks her season record for most points and least points in a game. Points scored in the first game establish her record for the season, and she begins counting from there. For example, assume her scores for the season are represented in the array scores=[12, 24, 10, 24]. Scores are in the same order as the games played. She would tabulate her results as f

View Solution →

Subarray Division

Given a chocolate bar, two children, Lily and Ron, are determining how to share it. Each of the squares has an integer on it. Lily decides to share a contiguous segment of the bar selected such that: The length of the segment matches Ron's birth month, and, The sum of the integers on the squares is equal to his birth day. You must determine how many ways she can divide the chocolate. Consider the chocolate bar as an array of squares, s = [2, 2, 1, 3, 2]. She wants to find segments sum

View Solution →

Divisible Sum Pairs

Given an array of integers and a positive integer k, determine the number of (i, j) pairs where i<j and ar[i] + ar[j] is divisible by k. Example ar = [1, 2, 3, 4, 5, 6] k=5 Three pairs meet the criteria: [1, 4], [2, 3] and [4, 6]. Function Description Complete the divisibleSumPairs function in the editor below. divisibleSumPairs has the following parameter(s): int n: the length of array int ar[n]: an array of integers int k: the integer divisor Returns - int: the num

View Solution →

Migratory Birds

Given an array of bird sightings where every element represents a bird type id, determine the id of the most frequently sighted type. If more than 1 type has been spotted that maximum amount, return the smallest of their ids. Example arr = [1, 1, 2, 2, 3] There are two each of types 1 and 2, and one sighting of type 3. Pick the lower of the two types seen twice: type 1. Function Description Complete the migratoryBirds function in the editor below. migratoryBirds has the following

View Solution →