title-img


Luck Balance

Lena is preparing for an important coding competition that is preceded by a number of sequential preliminary contests. Initially, her luck balance is 0. She believes in "saving luck", and wants to check her theory. Each contest is described by two integers, L[ i ] and T[ i ]: L[ i ] is the amount of luck associated with a contest. If Lena wins the contest, her luck balance will decrease by ; if she loses it, her luck balance will increase by L[ i ]. T[ i ] denotes the contest's importance ra

View Solution →

Greedy Florist

A group of friends want to buy a bouquet of flowers. The florist wants to maximize his number of new customers and the money he makes. To do this, he decides he'll multiply the price of each flower by the number of that customer's previously purchased flowers plus 1. The first flower will be original price, ( 0 + 1 ) * original price , the next will be ( 1 + 1 ) * original price and so on. Given the size of the group of friends, the number of flowers they want to purchase and the original pr

View Solution →

Max Min

You will be given a list of integers, arr , and a single integer k. You must create an array of length k from elements of arr such that its unfairness is minimized. Call that array arr' . Unfairness of an array is calculated as max( arr' ) - min( arr ' ) Where: - max denotes the largest integer in arr' . - min denotes the smallest integer in arr'. Note: Integers in may not be unique. Function Description Complete the maxMin function in the editor below. max

View Solution →

Reverse Shuffle Merge

Given a string, A, we define some operations on the string as follows: a. denotes the string obtained by reversing string . Example: b. denotes any string that's a permutation of string . Example: c. denotes any string that's obtained by interspersing the two strings & , maintaining the order of characters in both. For example, & , one possible result of could be , another could be , another could be and so on. Given a string such that for some string , find the lexico

View Solution →

Hash Tables: Ice Cream Parlor

Each time Sunny and Johnny take a trip to the Ice Cream Parlor, they pool their money to buy ice cream. On any given day, the parlor offers a line of flavors. Each flavor has a cost associated with it. Given the value of money and the cost of each flavor for trips to the Ice Cream Parlor, help Sunny and Johnny choose two distinct flavors such that they spend their entire pool of money during each visit. ID numbers are the 1- based index number associated with a cost. For each trip to the pa

View Solution →