Pages

Wednesday 30 August 2017

InterviewBit : Dynamic Programming : Arrange II

Problem

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:
  • You fill the horses into the stables preserving the relative order of horses. For instance, you cannot put horse 1 into stable 2 and horse 2 into stable 1. You have to preserve the ordering of the horses.
  • No stable should be empty and no horse should be left unaccommodated.
  • 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. 

Input 
string A = WWWB 
int K = 2

Output 
0

Saturday 19 August 2017

How to send mass emails from Gmail account

This post explains how to send mass emails using google spreadsheet and a simple google script from your gmail account.