Technical Interview at Verizon Media
I happened to be at Verizon Media for the technical discussion & below I will just give the information about the technical discussion there -
1st Round -
Question 1 : You are given array of random integers & you know that it can contain integers 1-50 only. Now you need to find
the missing numbers from that array.
Follow-up Questions I asked : Can the numbers be repeated in the provided array? Ans : Yes
Are all 1-50 number expected in the array? Ans : Yes
Is their performance or complexity constraint for the solution? Ans : No but can't use the
Collection API
The method code I wrote as below -
public class MissingNumbers {
public static void main(String[] args) {
int[] array = {1, 4, 3, 8, 9, 11, 15, 18, 20, 14, 4, 3, 8};
int[] result = find(array, 20);
for(int i : result) {
if(i == 0)
break;
System.out.println(i);
}
}
public static int[] find(int[] array, int size) {
boolean[] found = new boolean[size];
int length = array.length;
int[] result = new int[size];
for(int i = 0; i < length; i++) {
found[array[i]-1] = true;
}
int k = 0;
for(int i = 0; i < size; i++) {
if(!found[i]) {
result[k] = i+1;
k++;
}
}
return result;
}
}
Now the resulting array will have the missing integers & as soon as you hit '0', then it means no need to check more in the array. Instead of Boolean type array one can use Byte array, but will not cause much difference.
Then the question was on 'Default' 'Access Specifier'.
Next question was on Singleton Design pattern.
2nd Round -
Question 1 : You are given a 2 dimensional matrix of integers having both positive & negative integers. Now you have to find
the matrix where sum of all its numbers is minimum in all the possible matrices possible from given matrix.
Answer : I was not able to find the matrix but wrote the code to find the minimum sum of all number in the sub-matrix.
Will try to post the code for this here.
Question 2 : Write the code to create the pool of threads i.e. custom code like of Executor in Java.
Answer : It was not possible to write the code, but I just gave a brief idea on it.
1st Round -
Question 1 : You are given array of random integers & you know that it can contain integers 1-50 only. Now you need to find
the missing numbers from that array.
Follow-up Questions I asked : Can the numbers be repeated in the provided array? Ans : Yes
Are all 1-50 number expected in the array? Ans : Yes
Is their performance or complexity constraint for the solution? Ans : No but can't use the
Collection API
The method code I wrote as below -
public class MissingNumbers {
public static void main(String[] args) {
int[] array = {1, 4, 3, 8, 9, 11, 15, 18, 20, 14, 4, 3, 8};
int[] result = find(array, 20);
for(int i : result) {
if(i == 0)
break;
System.out.println(i);
}
}
public static int[] find(int[] array, int size) {
boolean[] found = new boolean[size];
int length = array.length;
int[] result = new int[size];
for(int i = 0; i < length; i++) {
found[array[i]-1] = true;
}
int k = 0;
for(int i = 0; i < size; i++) {
if(!found[i]) {
result[k] = i+1;
k++;
}
}
return result;
}
}
Now the resulting array will have the missing integers & as soon as you hit '0', then it means no need to check more in the array. Instead of Boolean type array one can use Byte array, but will not cause much difference.
Then the question was on 'Default' 'Access Specifier'.
Next question was on Singleton Design pattern.
2nd Round -
Question 1 : You are given a 2 dimensional matrix of integers having both positive & negative integers. Now you have to find
the matrix where sum of all its numbers is minimum in all the possible matrices possible from given matrix.
Answer : I was not able to find the matrix but wrote the code to find the minimum sum of all number in the sub-matrix.
Will try to post the code for this here.
Question 2 : Write the code to create the pool of threads i.e. custom code like of Executor in Java.
Answer : It was not possible to write the code, but I just gave a brief idea on it.