Two quant interview questions (one stat, one programming) - need help!!!

Joined
11/28/16
Messages
1
Points
11
1 You are given a list (n <= 100) of positive integers (value <= 500), your program divides these integers into two groups, such that the difference between the sums of these two groups is minimized. Here are some examples:
Example 1:
Input: 1 1 1 2 2
Output: (1 1 1)(2 2) => 1
(difference between 3 and 4)

2 In statistics, linear regression refers to an approach for modeling the relationship between a scalar response variable and one or more explanatory variables.
a) How would you construct a small data set (less than 50 data points) with 2 explanatory variables, such that both explanatory variables and the response variable are Gaussian, but the residual of the linear regression is not Gaussian?
b) How would you construct a small data set (less than 50 data points) with 2 explanatory variables, such that neither the explanatory variables nor the response variable is Gaussian, but the residual of the linear regression is Gaussian?
 
My answer for problem 1.
First sort the list
Then start from the largest number. Put the largest number in list1.
Then put the second largest number and the third largest number in list2.
For the 4th to the least largest number, put it in list1 if the sum of list1 is smaller than or equal to the sum of list2. Else put it in list2.
 
Back
Top