## Recent Interview Questions

More Questions »- 0of 0 votes
Do STL containers always create copy of objects when containers are populated (e.g. if you have a vector<A> or a map<int, A>, when we insert elements into vector/map, whether copies of object of class A would be stored inside the vector/map?

- 0of 0 votes
How would one design a multi format converter that supports reading data from multiple data sources(web service, local disk, etc.). The data from the sources can be in multiple formats. The reader for each format may be different and how does one serialize this abstract data to multiple formats like image, xml etc. New readers, writers and data sources can be added later during implementation.

- 0of 0 votes
As you are on Seattle, tell me how many rain drops pour on earth every year

- 0of 0 votes
We have a bag containing numbers 1, 2, 3, …, 100. Each number appears exactly once, so there are 100 numbers. Now one number is randomly picked out of the bag. Find the missing number.

- 0of 0 votes
Given an array of non-repeating, non-sorted, positive and negative integers, find 4 numbers in that array which satisfy the following equation: A1 + A2 + A3 = A4

Complete the function to return the value A4. If no such numbers satisfy the given equation, return -1,

In case of multiple possibilities that satisfy the equation, return the largest such value of A4.

Sample Test Case:

Sample Input: {-6,2,4,8}

Sample Output: 4

Explanation: The value 4 can be achieved as follows: 8+2+(-6) = 4

IMPORTANT: You do not need to write full code. Just complete the given function.`/**This class find sequence of elements in an array which satifies a1+a2+a3=a4. * @author Kishor Kumar Padhan * */ public class EquationInArray { public static void main(String[] args) { int[] arr = new int[] {-6,2,4,8}; int[][] arr1 = new int[arr.length*(arr.length-1)][2]; int k=0; for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr.length; j++) { if(i!=j) { arr1[k][0] = arr[i]; arr1[k][1] = arr[j]; k++; } } } int bigMatchedNumber=0; String bigMatchedEquation=""; int m=0; while(m<arr1.length) { for(int n=0;n<arr.length;n++) { if(arr1[m][0]!=arr1[n][1] && arr1[m][1]!=arr1[n][1]) { int total = arr1[m][0]+arr1[m][1]+arr1[n][1]; if(doesNumberExists(total,arr)) { if(total>bigMatchedNumber) { bigMatchedNumber=total; bigMatchedEquation = arr1[m][0]+"+"+arr1[m][1]+"+"+arr1[n][1]+"="+total; } } } } m++; } System.out.println("bigMatchedEquation : " + bigMatchedEquation); } private static boolean doesNumberExists(int total, int[] arr) { boolean matched = false; for (int i = 0; i < arr.length; i++) { if(total == arr[i]) { matched = true; } } return matched; } }`