Microsoft Interview Question: Find the maximum product of 3... | Glassdoor

Interview Question

Software Developer Interview(Student Candidate) Redmond, WA

Find the maximum product of 3 numbers in a list.

Answer

Interview Answer

3 Answers

0

Couldn't answer during the interview. Afterwords I figured out you can check all permutations of the largest 3 and (most negative) 3 numbers in constant O(1) time.

Interview Candidate on Nov 29, 2015
0

you just need 2 most negative numbers

Anonymous on Apr 23, 2016
0

This is a simple Dynamic puzzle:
```
    int max(int[] num) {
        int[] list = new int[num.length];
        list[0] = num[0];
        for (int i = 1; i list[i]) {
                list[i] = list[i-1] * num[i];
            }
            else {
                list[i] = list[i-1];
            }
        }
        return list[list.length - 1];
    }
```

Anonymous on Dec 1, 2016

Add Answers or Comments

To comment on this, Sign In or Sign Up.