Morgan Stanley

  www.morganstanley.com
Work in HR? Unlock Free Profile

Morgan Stanley Analyst Interview Question (student candidate)

I interviewed in New York, NY and was asked:
"There are 3 types of coins. The values are 1, 2, 5, respectively. What's the algorithm to get the minimun number of coins if the sum of them is N?"
Tags: technical, algorithm
Add Tags [?]
Answer

Part of a Analyst Interview Review - one of 981 Morgan Stanley Interview Reviews

Answers & Comments

0
of 0
votes

dynamic programming

- Interview Candidate on Sep 05, 2012
0
of 0
votes

(function foo(n){
    var coins = [1,2,5]
    var num = 0;
    while (coins.length){
        var coin = coins.pop()
        num+= Math.floor(n/coin);
        n=n%coin;
        if(!n) break;
    }
    console.log(num);
})(28)

- grim face on Sep 07, 2012

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords, helping to categorise interview questions that have something in common.