Amazon Interview Question for SDE1s
- 4of 6 votes
You are given a sequence of black and white horses, and a set of k stables numbered 1 to k. You have to accommodate the horses into the stables in such a way that the following conditions are satisfied:- nishu May 21, 2014 in India
a. You fill the horses into the stables preserving the order of horses. For instance, you cannot put for horse 1 into stable 2 and horse 2 into stable 1. You have to preserve the ordering of horses.
b. No stable should be empty and No horse should be left unaccommodated.
c. Take the product (number of white horses * number of black horses) for each stable and take the sum of all these products. This value should be the minimum among all possible accommodation arrangements.
| Report Duplicate | Flag | PURGE
Open Chat in New Window