Recent Interview Questions
 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 nonrepeating, nonsorted, 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.length1)][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; } }
 0of 0 votes
Find the maximum sum subset in an array with negative integers
 0of 0 votes
find the Maximum product subset with negative and positive integer
 0of 0 votes
Given a string of n characters how would you replace all occurrences of a particular character with some other character with a time complexity less than O(n)?
Note: W/o using any inbuilt string replace functions of the language.
 1of 1 vote
/**
* Implement a function OneEditApart with the following signature:
* bool OneEditApart(string s1, string s2)
*
* OneEditApart("cat", "dog") = false
* OneEditApart("cat", "cats") = true
* OneEditApart("cat", "cut") = true
* OneEditApart("cat", "cast") = true
* OneEditApart("cat", "at") = true
* OneEditApart("cat", "acts") = false
* Edit is: insertion, removal, replacement
*/
 0of 0 votes
Given the following filename/rules:
johndoe_sdfjkldfj_ldfjlkfdsjfds_dfdjklfdsjs.txt
Rules:
johndoe is a distinct identifier (not a constant)
any following items are tacked on with underscores separating them and each token contains a key value pair. The key is the first character and the value is the remaining characters.
Parse this filename and return a dictionary/hashtable of values, removing any file extensions but also keeping in mind that this filename could end up with incorrect characters or incorrect amounts of characters.
Example input:
johndoe_sdfjkldfj_ldfjlkfdsjfds_dfdjklfdsjs.txt
Example output:
@{ @"NAME" : @"johndoe",
@"s" : @"dfjkldfj",
@"l" : @"dfjlkfdsjfds",
@"d": @"fdjklfdsjs"
};
Followup: How would you handle it if you found multiple tokens with the same key?
 0of 0 votes
Design and code the logic software for an elevator, pretending like the hardware is already there for you with the following APIs:
 OpenDoor()
 GotoFloor()
 0of 0 votes
Given 2 sorted lists that are of even and equal size, output the median. If there is no middle number, return the average of the 2 middle numbers
 0of 0 votes
Given an array of words, write a method that determines whether there are any words in this array that are anagrams of each other.
Sample #1: @[@"bag", @"bat", @"tab"]; // output TRUE
Sample #2: @[@"gab", @"bat", @"laf"]; // output FALSE
 0of 0 votes
An UIView A2 is subclassed from the same parent as an UIView A1.
Given inputs of A1, A2, and an UIView that is in the tree of UIViews of A1 somewhere, return the exact UIView that mirrors this in A2.
Example setup:
A1
 
UIView UIView

UIView < Given this
A2
 
UIView UIView

UIView < Find/return this
 0of 0 votes
Given a list of n sorted lists of numbers, write a method that returns one giant list of all the numbers in order.
Example input:
NSArray* input = @[
@[@2, @5, @10],
@[@25, @100, @105],
@[@7, @56, @42],
.......
];
 0of 0 votes
Given the following hashmap for numeric to alpha translation of a telephone keypad:
NSDictionary* dict = @{@2: @[@"A", @"B", @"C"],
@3: @[@"D", @"E", @"F"],
@4: @[@"G", @"H", @"I"],
@5: @[@"J", @"K", @"L"],
@6: @[@"M", @"N", @"O"],
@7: @[@"P", @"Q", @"R", @"S"],
@8: @[@"T", @"U", @"V"],
@9: @[@"W", @"X", @"Y", @"Z"]};
Write a method that takes a phone number as input and returns all possible letter combinations for that phone number.
 0of 0 votes
How would you speed up dynamically generated web content?
 0of 0 votes
Given a spreadsheet program, determine a method to prevent recursive formula calculation
 0of 0 votes
How can we achieve something similar to polymorphism in C language? Polymorphism is an OOPs feature.
 0of 0 votes
Write test cases for a software which accepts inputs as dd/mm/yyyy and gives output as 4 days after the input.
exinput07/01/2011..out put should be 11/01/2011.
give boundary values of each test cases..assume dd/mm/yyyy in correct format
 0of 0 votes
implement division without using division operator in log(n) time.
 0of 0 votes
Can we write a collection class in C++ that can store elements of different data types?
 0of 0 votes
8 coins are given where all the coins have equal weight, except one. The odd one may be less weight than the other or it may be heavier than the rest 7 coins. In worst case, how many iterations are needed to find the odd one out?
 1of 1 vote
An array which is a Post order traversal of a Binary Tree. Write a function to check if the Binary Tree formed from the array is a Binary Search Tree.
Eg:
2
1 3
The array given as input would be 1 3 2.
Write a function to say if the tree formed is a Binary Search Tree.
Example 2: 4 is root. 0 is left child of 1 , 1 is left child of 2 and 2 is left child of 4. 5 is right child of 4 and 6 is right child of 5.
4
2 5
1 6
0
0 1 2 6 5 4 is the input array.
 0of 0 votes
Observe the following function declaration and choose the best answer:
int divide ( int a, int b = 2 )
 0of 0 votes
Given a set of integral coordinates, find the minimum area of a rectangle that can be drawn to encompass all the points. The sides of such a rectangle have to be parallel to the two axes. Return the area of the rectangle.
Sample Test Case
Sample Input:
4
1 1
1 4
2 2
5 3
Sample Output: 12
Explanation: The points are (1,1) , (1,4) , (2,2) and (5,3) and the area of the rectangle that encompasses all the points is 12.
 0of 0 votes
Given an array of integers, sort the array into a wave like array, namely
a1 >= a2 <= a3 >= a4 <= a5.....
 0of 0 votes
Give this input: Sea!tle is a nice place. Work Hard! have Fun, make HIStory!
display this output using any C or vb script:
Seattle is a nice place.
Work hard.
Have fun.
Make history.
 0of 0 votes
Given three strings str1, str2 and str3; complete the function to find the smallest subsequence in str1 which contains all the characters in str2 (in any order) and not those in str3.
Sample Test Case:
Sample Input:
str1: spqrstrupvqw
str2: sprt
str3: q
Sample Output: strup
Explanation: In the given string str1, the smallest subsequence that contains the characters in str2 ( 's' , 'p' , 'r' , 't' ) and does not contain the character in str3 ( 'q' ) is 'strup'.
 0of 0 votes
Design a website like Paypal.
The interviewer was interested in the
i) Major components & the way they will interact.
ii) Various way of scaling the website to support many users
iii) Handling the failure cases like when the DB goes down, etc.
 0of 0 votes
Given a binary matrix of 0 and 1. Find the longest sequence of 1's either row wise or column wise.
For example
0 0 0 0 0 0
0 1 1 1 0 0
0 0 0 1 0 0
It should return 1 1 1
 0of 0 votes
Can anyone tell me that from where i can get/download java code on Ray Casting Algorithms or Point in Polygon algorithms? or any library is avaiable.