2010年12月8日 星期三

Yahoo phone interview

1. Given an int array, verify if there exist a pair of numbers which has sum to 100. For example,
    {1, 5, 99} -> True
    {1, 5, 100} -> False
    Hint: Sort & use two cursor in opposite direction. One from begin, one from end

2.a Thee is a currency system has 1 cent, 5 cents, 10 and 25. Design a function compute minimum number of coins for an amount of money. For example, f(7) = 3 for {1,1,5}
    Hint: Greedy

2.b Give a currency system that cannot be solved by greedy algorithm
2.c How do you solve the problem in 2.b? DP      

沒有留言:

張貼留言