Common Child
A string is said to be a child of a another string if it can be formed by deleting 0 or more characters from the other string. Given two strings of equal length, what's the longest string that can be constructed such that it is a child of both? For example, ABCD and ABDC have two children with maximum length 3, ABC and ABD. They can be formed by eliminating either the D or C from both strings. Note that we will not consider ABCD as a common child because we can't rearrange characters and ABCD
View Solution →Minimum Absolute Difference in an Array
The absolute difference is the positive difference between two values a and b, is written | a - b | or | b - a | and they are equal. If a = 3 and b = 20, | 3 - 2 | = | 2 - 3 | = 1 . Given an array of integers, find the minimum absolute difference between any two elements in the array. Function Description Complete the minimumAbsoluteDifference function in the editor below. It should return an integer that represents the minimum absolute difference between any pair of elements. mini
View Solution →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 →