## Choosing White Balls

There are n balls in a row, and each ball is either black (B) or white (W). Perform k removal operations with the goal of maximizing the number of white balls picked. For each operation i (where 1 <= i <=k): 1.Choose an integer, xi, uniformly and independently from 1 to n-i+1 (inclusive). 2.Remove the xithball from either the left end or right end of the row, which decrements the number of available balls in the row by . You can choose to remove the ball from whichever end in each step maxi

View Solution →## Mandragora Forest

The evil forest is guarded by vicious mandragoras. Garnet and her pet must make a journey through. She starts with 1 health point (s) and 0 experience points. As she encouters each mandragora, her choices are: 1. Garnet's pet eats mandragora i. This increments s by 1 and defeats mandragora i. 2.Garnet's pet battles mandragora i. This increases p by s * H[i] experience points and defeats mandragora i. Once she defeats a mandragora, it is out of play. Given a list of mandragoras with vario

View Solution →## Red John is Back

Red John has committed another murder. This time, he doesn't leave a red smiley behind. Instead he leaves a puzzle for Patrick Jane to solve. He also texts Teresa Lisbon that if Patrick is successful, he will turn himself in. The puzzle begins as follows. There is a wall of size 4xn in the victim's house. The victim has an infinite supply of bricks of size 4x1 and 1x4 in her house. There is a hidden safe which can only be opened by a particular configuration of bricks. First we must calculate

View Solution →## LCS Returns

Given two strings, a and b, find and print the total number of ways to insert a character at any position in string a such that the length of the Longest Common Subsequence of characters in the two strings increases by one. Input Format The first line contains a single string denoting a. The second line contains a single string denoting b. Constraints Scoring 1 <= |a|,|b| <= 5000 Strings a and b are alphanumeric (i.e., consisting of arabic digits and/or upper and lower case Engl

View Solution →## Grid Walking

You are situated in an n dimensional grid at position (x[1],x[2],...,x[n]). The dimensions of the grid are D[1],D[2],...,D[n]). In one step, you can walk one step ahead or behind in any one of the n dimensions. This implies that there are always 2*n possible moves if movements are unconstrained by grid boundaries. How many ways can you take m steps without leaving the grid at any point? You leave the grid if at any point x[i], either x[i] <= 0 or x[i] >D[i]. For example, you start off in a 3

View Solution →