摘要:
You have k lists of sorted integers. Find the smallest range that includes at least one number from each of the k lists. 阅读全文
2013年10月31日
2013年10月30日
摘要:
Pots of gold game: Two players A & B. There are pots of gold arranged in a line, each containing some gold coins (the players can see how many coins are there in each gold pot - perfect information). They get alternating turns in which the player can pick a pot from one of the ends of the line. The winner is the player which has a higher number of coins at the end. The objective is to "maximize" the number of coins collected by A, assuming B also plays optimally. A starts the game.
The idea is 阅读全文
2013年10月29日
摘要:
Given an array of integers. Find two disjoint contiguous sub-arrays such that the absolute difference between the sum of two sub-array is maximum.
* The sub-arrays should not overlap.
eg- [2 -1 -2 1 -4 2 8] ans - (-1 -2 1 -4) (2 8), diff = 16 阅读全文
摘要:
there are 81 horses. you need to select the first best 6 horses. Each time only 9 horses can participate. how many minimum no. of races you require 阅读全文
2013年10月28日
摘要:
Given 25 horses, find the best 3 horses with minimum number of races. Each race can have only 5 horses. You don't have a timer. 阅读全文
2013年10月25日
摘要:
Simulate a seven-sided die using only five-sided 阅读全文
摘要:
If a=1, b=2, c=3,....z=26. Given a string, find all possible codes that string can generate. Give a count as well as print the strings.
For example:
Input: "1123". You need to general all valid alphabet codes from this string. 阅读全文
2013年10月24日
摘要:
Given an integer array, sort the integer array such that the concatenated integer of the result array is max. e.g. [4, 94, 9, 14, 1] will be sorted to [9,94,4,14,1] where the result integer is 9944141 阅读全文
2013年10月23日
摘要:
If [a1,a2,a3...,an,b1,b2...bn] is given input change this to [a1,b1,a2,b2.....an,bn] , solution should be in-place 阅读全文
2013年10月22日
摘要:
Design an algorithm that, given a list of n elements in an array, finds all the elements that appear more than n/3 times in the list. The algorithm should run in linear time ( n >=0 ) 阅读全文