Garmin
3.4 of 5 216 reviews
www.garmin.com Olathe, KS 5000+ Employees

Garmin Software Engineer Interview Question

I interviewed in Olathe, KS and was asked:
"Write an algorithm in any programming language for calculating the amount of change needed. As a follow up, can you modify this algorithm to avoid using the division operator?"
Add Tags [?]
Answer Flag Question

Part of a Software Engineer Interview Review - one of 136 Garmin Interview Reviews

Answers & Comments

0
of 0
votes
Initially I incorrectly used the modulus operator, but later in the interview recalled the correct usage which should have been division.
- Interview Candidate on Sep 11, 2010 Flag Response
0
of 0
votes
Garmin would probably like to see this in C, but here's a quick solution in Java that doesn't need division:

    private static int countDenominations(int n, int[] denominations) {
        return countDenominationsHelper(n, denominations, 0);
    }

    private static int countDenominationsHelper(int n, int[] denominations, int i) {
        if (n == 0) {
            return 1;
        }

        if (n < 0) {
            return 0;
        }

        if (i >= denominations.length) {
            return 0;
        }

        return countDenominationsHelper(n - denominations[i], denominations, i) +
                    countDenominationsHelper(n, denominations, i + 1);
    }
- guy on Dec 19, 2012 Flag Response

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


Tags are like keywords that help categorize interview questions that have something in common.

Glassdoor is your free inside look at Garmin interview questions and advice. All interview reviews posted anonymously by Garmin employees and interview candidates.