Ice Cream Parlor
Two friends like to pool their money and go to the ice cream parlor. They always choose two distinct flavors and they spend all of their money. Given a list of prices for the flavors of ice cream, select the two that will cost all of the money they have. Example. The two flavors that cost and meet the criteria. Using -based indexing, they are at indices and . Function Description Complete the icecreamParlor function in the editor below. icecreamParlor has the following par
View Solution →KnightL on a Chessboard
KnightL is a chess piece that moves in an L shape. We define the possible moves of as any movement from some position to some satisfying either of the following: Note that and allow for the same exact set of movements. For example, the diagram below depicts the possible locations that or can move to from its current location at the center of a chessboard: Observe that for each possible movement, the Knight moves units in one direction (i.e., horizontal or vertical) and unit i
View Solution →Minimum Loss
Lauren has a chart of distinct projected prices for a house over the next several years. She must buy the house in one year and sell it in another, and she must do so at a loss. She wants to minimize her financial loss. Function Description Complete the minimumLoss function in the editor below. minimumLoss has the following parameter(s): int price[n]: home prices at each year Returns int: the minimum loss possible Input Format The first line contains an integer n, the num
View Solution →Missing Numbers
Given two arrays of integers, find which elements in the second array are missing from the first array. Notes If a number occurs multiple times in the lists, you must ensure that the frequency of that number in both lists is the same. If that is not the case, then it is also a missing number. Return the missing numbers sorted ascending. Only include a missing number once, even if it is missing multiple times. The difference between the maximum and minimum numbers in the original list is
View Solution →Pairs
Given an array of integers and a target value, determine the number of pairs of array elements that have a difference equal to the target value. Function Description Complete the pairs function below. pairs has the following parameter(s): int k: an integer, the target difference int arr[n]: an array of integers Returns int: the number of pairs that satisfy the criterion Input Format The first line contains two space-separated integers n and k, the size of arr and the targe
View Solution →