March 27, 2015

Google code jam :Minimum Scalar Product

Problem
You are given two vectors v1=(x1,x2,...,xn) and v2=(y1,y2,...,yn). The scalar product of these vectors is a single number, calculated as x1y1+x2y2+...+xnyn.
Suppose you are allowed to permute the coordinates of each vector as you wish. Choose two permutations such that the scalar product of your two new vectors is the smallest possible, and output that minimum scalar product.

March 26, 2015

Google Code jam:Reverse Words in O(nm)


Problem
Given a list of space separated words, reverse the order of the words. Each line of text contains L letters and W words. A line will only consist of letters and space characters. There will be exactly one space character between each pair of consecutive words.

March 25, 2015

Nagarro:GenerateNextDate

Question: Write a function char[] GenerateNextDate(char[]) such that if a date of the format "23Jan201 2" is input, the next date should be produced.

Eg: Input ­ "12-Dec-1987"
Output ­ "13-Dec-1987"
Please remember the input and output are both strings.

March 22, 2015

Google Code jam:StoreCredit

Problem

You receive a credit C at a local store and would like to buy two items. You first walk through the store and create a list L of all available items. From this list you would like to buy two items that add up to the entire value of the credit. The solution you provide will consist of the two integers indicating the positions of the items in your list (smaller number first).