## Largest Permutation

You are given an unordered array of unique integers incrementing from . You can swap any two elements a limited number of times. Determine the largest lexicographical value array that can be created by executing no more than the limited number of swaps. Example The following arrays can be formed by swapping the with the other elements: [2,1,3,4] [3,2,1,4] [4,2,3,1] The highest value of the four (including the original) is . If , we can swap to the highest possible value: . Func

View Solution →## Mark and Toys

Mark and Jane are very happy after having their first child. Their son loves toys, so Mark wants to buy some. There are a number of different toys lying in front of him, tagged with their prices. Mark has only a certain amount to spend, and he wants to maximize the number of toys he buys with this money. Given a list of toy prices and an amount to spend, determine the maximum number of gifts he can buy. Function Description Complete the function maximumToys in the editor below. maximumT

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 →## Jim and the Orders

Jim's Burgers has a line of hungry customers. Orders vary in the time it takes to prepare them. Determine the order the customers receive their orders. Start by numbering each of the customers from to , front of the line to the back. You will then be given an order number and a preparation time for each customer. The time of delivery is calculated as the sum of the order number and the preparation time. If two orders are delivered at the same time, assume they are delivered in ascending cust

View Solution →