title-img


Day of the Programmer

Marie invented a Time Machine and wants to test it by time-traveling to visit Russia on the Day of the Programmer (the 256th day of the year) during a year in the inclusive range from 1700 to 2700. From 1700 to 1917, Russia's official calendar was the Julian calendar; since 1919 they used the Gregorian calendar system. The transition from the Julian to Gregorian calendar system occurred in 1918, when the next day after January 31st was February 14th. This means that in 1918, February 14th was

View Solution →

Bill Division

Two friends Anna and Brian, are deciding how to split the bill at a dinner. Each will only pay for the items they consume. Brian gets the check and calculates Anna's portion. You must determine if his calculation is correct. For example, assume the bill has the following prices: bill = [2, 4, 6]. Anna declines to eat item k= bill[2] which costs 6. If Brian calculates the bill correctly, Anna will pay (2+4)/2 = 3. If he includes the cost of bill[2], he will calculate (2 + 4 +6)/2 =6. In the se

View Solution →

Triple sum

Given 3 arrays a, b , c of different sizes, find the number of distinct triplets ( p , q , r ) where p is an element of a, written as , , and , satisfying the criteria: p <= q and q > = r . Function Description Complete the triplets function in the editor below. It must return the number of distinct triplets that can be formed from the given arrays. triplets has the following parameter(s): a, b, c: three arrays of integers . Input Format The first line contains 3 integers lena

View Solution →

Minimum Time Required

You are planning production for an order. You have a number of machines that each have a fixed number of days to produce an item. Given that all the machines operate simultaneously, determine the minimum number of days to produce the required order. For example, you have to produce goal = 10 items. You have three machines that take machines = [2, 3, 2 ] days to produce an item. The following is a schedule of items produced: Day Production Count 2 2 2 3 1

View Solution →

Maximum Subarray Sum

We define the following: A subarray of array a of length n is a contiguous segment from a[ i ] through a[ j ] where 0 <= i <= j < n. The sum of an array is the sum of its elements. Given an n element array of integers, a, and an integer, m , determine the maximum value of the sum of any of its subarrays modulo m. For example, Assume a = [1, 2, 3 ]and m = 2 . The following table lists all subarrays and their moduli: sum %2 [1] 1 1 [2] 2 0 [3] 3 1 [1,2] 3 1 [2,3] 5 1 [1,2

View Solution →