Coding Interview Questions
- 0of 0 votes
Answersfind the balance index of an array where balanced index i is defined as the one whose left sum is equal to the right sum of the index .
- softy July 15, 2012 in India for bing
i.e
summation (1 to i-1) = summation (i+1 to length of an array) firdt I gave o(n2) solution , but then before i could give O(n) solution it was time up for me,
O(n) solution will be we have to loop through i = 1 to N and find if ( sum of array - sum of array (1 to i-1 ) = ( sum of array - sum of array (1 to i+1 ) the return i.
Your thoughts?| Report Duplicate | Flag | PURGE
Microsoft Algorithm Arrays Coding Data Structures - 0of 0 votes
AnswersPrint list ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] in 3 columns.
- tazo July 14, 2012 in United States
Example output:
a e i
b f j
c g
d h| Report Duplicate | Flag | PURGE
Software Engineer / Developer Coding - 0of 0 votes
AnswersUser inputs a series of numbers and terminates the series by a zero. Your program should find the first three maximum values in the series and exclude them from the series and compute the average of the remaining numbers. (excluding zero as well)
- ranechabria July 14, 2012 in United States
Ex - 3, 7, 12, 2, 25, 8, 9, 13, 10, 0
First three maximum numbers = 25, 13, 12
Average of the rest = (3 + 7 + 2 + 8 + 9 + 10) / 6 = 6.5| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm Coding - 2of 2 votes
AnswersUser inputs a sequence of digits. Every digit is a keystroke, that is equivalent to some character out of a sequence of characters. Digit zero and five mean NULL. The table is given below
- ranechabria July 14, 2012 in United States
0 - NULL
1 - v, t, f, r, q
2 - f, t, k
3 - w, z, b, g
4 - r, s
5 - NULL
6 - f, i, r
7 - p
8 - l, o
9 - p
Generate all possible character sequence for a given sequence of digits.
Ex - If the user input 9801, your program should generate
{plv, plt, plf, plr, plq, pov, pot, pof, por, poq} (not necessarily in this order).
This problem is somewhat similar to the SMS problem. It basically boils down to generating a cartesian product of the character sets corresponding to keys.| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm Coding Data Structures - 1of 1 vote
AnswersImplement the plusplus operator when we are getting the input as integer array = { 9,9,9,9 }.output will be {1,0,0,0,0}
- JobHunter July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays C Coding Data Structures - 0of 4 votes
AnswersWrite a pseudo code. The question aims to test both your programming and analytical skills. Your implementation will be tested for both time and space efficiency.
- br312@live.co.uk July 04, 2012 in United States
The input format is strictly followed. Your program will be evaluated for correctness against multiple inputs. Some inputs will be very large (> 100,000 nodes).
Problem Statement
You are in-charge of the office jukebox. You are determined to do a very good job and make your colleagues happy. You ask them to email you a list of music bands they like. The number of bands each colleague likes is limited to 10,000.
Input
All input will be given on stdin. Your input will be of the form,
1. The first line will be an integer stating the number of lines of input.
2. The input will only contain alphanumeric characters, colon, comma, underscore and space [A-Z, a-z, 0-9, _, , ], +.
3. The first word will be the name of your colleague, followed by a colon.
4. A comma separated list of that person’s favourite bands will follow the colon.
5. Every line will be terminated by a newline character (\n).
An example input would look like:
6
Anne: Metallica, The_Doors, Black_Sabbath
John: The_Beatles, The_Doors, Metallica, Pink_Floyd
Kathy: U2, Guns_n_Roses, Led_Zeppelin
Jamie: Radiohead
Ashok: Guns_n_Roses, U2, Pink_Floyd, The_Doors
Sara: Blink_182, Iron_Maiden, The_Doors
Problem
You decide to use your data to find the people most compatible with each other. Two people are compatible if they have at least 2 bands in common. The compatibility of two people is directly proportional to the number of bands they like in common.
For each person in the list, output the most compatible person(s). If there is more than one compatible person, separate the names with a comma. If a person has nobody compatible, output nothing. For our example input, the output will be,
Anne: John
John: Anne, Ashok
Kathy: Ashok
Jamie:
Ashok: John, Kathy
Sara:| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Coding - 0of 0 votes
AnswersExpression: 5 + 3 * ( 6 - 4 ) solve the expression from left to write as well as solve the sub ex-expressions from left to right (without using BEDMAS), take the given expression as string input, and print the output....note in this expression a white space has been added on both operators and operands?
- kk June 23, 2012 in India
Example: Input : 5 + 3 * ( 6 - 4 )
output : 16
(if you use BEDMAS rule then you get the output : 11)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 0of 0 votes
AnswersToday I attended Amazon interview for the position of Programmer Analyst at Chennai.....Here I've post it, some of the questions they asked,
- kk June 23, 2012 in India
1. write the code ofTwo large numbers ( their integer limits are very large which has not in the integers range) , so give the output of adding the two large numbers?
Example;
str1 ="1111111111111111111111111111111111111111"
str2 ="22222222222222222222222222222222222222222"
stmstr = "33333333333333333333333333333333333333333"
(it has 41 digits that i've counted)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 0of 0 votes
AnswersExtend the JavaScript Array object by adding a method that removes duplicates.
- niharika.verma June 21, 2012 in United States| Report Duplicate | Flag | PURGE
Ebay Front-end Software Engineer Coding - 3of 3 votes
AnswersQ1.- Written exam (Amazon, Bangalore)
- Nitin Gupta May 12, 2012 in India
Given a singly link list and a number 'K', swap the Kth node from the start with the Kth node from the last. Check all the edge cases.
Sample Input: 1->2->3->4->5->6->7->8 and K = 3
Sample Output : 1->2->6->4->5->3->7->8
Sample Input: 1->2->3->4->5->6->7->8 and K = 10
Sample Output: print error "LIST IS OF LESSER SIZE".| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm C C# C++ Coding Data Structures Java Linked Lists - 0of 0 votes
AnswersQ2. F2F Round-1, Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given an array of integers having the property that first that array is strictly increasing then it is strictly decreasing, You have to search for a given number.
Constraint: Minimize the complexity| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays C C# C++ Coding Data Structures Java - 0of 0 votes
AnswersQ1. F2F Round 1 Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given a character array as input. Array contains only three types of characters 'R', 'G' and 'B'. Sort the array such that all 'R's comes before 'G's and all 'G's comes before 'B's.
Constraint :- No extra space allowed(except O(1) space like variables) and minimize the time complexity.
You can only traverse the array once.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays C C# C++ Coding Data Structures Java Sorting - 0of 0 votes
AnswersQ4. Written Exam Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given an array of integers A[1....n-1] where 'N' is the length of array A[ ]. Construct an array B such that B[i] = min(A[i], A[i+1], ......., A[i-K+1]), where K will be given.
Array B will have N-K+1 elements.
Constraint: Extra space allowed O(K) and time complexity allowed O(N.K) or lower.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays C C# C++ Coding Data Structures Java Sorting - 1of 1 vote
AnswersQ3. Written Exam Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given a singly linked list which may or may not contain loop and loop may or may not start from the head node. Count the number of elements in the linked list.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm C C# C++ Coding Data Structures Java Linked Lists - 0of 0 votes
AnswersQ2. Written Exam Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given a number in the form of string. Output the binary equivalent of that number.
Sample Input: "8.5"
Sample Output: 1000.1
Sample Input: "12.34.23"
Sample Output: "ERROR"| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm C C# C++ Coding Java Math & Computation - 0of 0 votes
AnswersCode to find endianness of a machine.
- dareyouspam May 06, 2012 in United States| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer / Developer C Coding - 0of 0 votes
AnswersWrite code to check the string is palindrome
- terryocy April 27, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - -1of 1 vote
Answersprint 2n+1 prime numbers if any one of them not prime then print factors for that number
- Anonymous April 21, 2012 in India| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Arrays C Coding - -1of 1 vote
Answerswrite a program to print the given string as alphabets in order next integres fallowed by sum
- Anonymous April 21, 2012 in India
example: CAE2W3A is input and output should be
ACDEW5| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Arrays Coding - 0of 0 votes
AnswersHi.. i had an inperson interview in a small startup company and i was asked to code.. the ques is as follow. I need to asume about the microprocessor and detectors in the US roads which detects the cars passing o the road. so i need to count 1 for every sec and prnt total no of sec, if the detecter detects a car passing by i need to say 2 and print the number of cars passed and also i need to calc the maximum time difference betwesn the two cars which passed.. if anyone knows the soln please post it. and he gave me a methos int getevent() and i was asked to write all these withing this method and all shuld be whithin just one loop.
- me.studywell April 14, 2012 in United States| Report Duplicate | Flag | PURGE
Software Engineer / Developer Coding - 0of 0 votes
AnswersThe same Glitch Robot question whihc is posted on the nexxt page with the only variation that the robot makes a turn every 100 steps...I found this question tuff and it consumed a lot of time.
- XXX April 13, 2012 in United States| Report Duplicate | Flag | PURGE
Coding - 0of 0 votes
AnswersWithout using /,% ,+and * operators. write a function to check whether a number is divisible by 3 or nor??
- abhishek April 12, 2012 in India| Report Duplicate | Flag | PURGE
Adobe Coding - 0of 0 votes
AnswersWAP to find nth Fibonacci number. After I wrote the code, had to read it out line by line. then she asked follow up questions like why this method, what other ways you can write the algorithm, etc.,
- Sr April 02, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Coding - 0of 0 votes
AnswersWAP to count the num of possible hops the bunny can make. conditions are -
- Sr April 02, 2012 in United States
- bunnies are positions of bunnies on a number line
- count the number of valid hops
- A bunny at the position 'a' jumps over bunny at position 'b' and lands at the position c, c = 2b-a
- A bunny can only hop over one other bunny, and cannot land on another bunny.
- There are at least two bunnies.
- The bunnies are in sorted array.
- The bunny can hop in both directions.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Coding - 0of 0 votes
AnswersSimple one to write a program to calculate avg of int array.
- Sr April 02, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Coding - 0of 0 votes
Answerspublic void myFunction(int n)
- Ray Sun March 29, 2012 in United States for Kindle
{
if (n == 0)
return;
else
{
print(n);
myFunction(n--);
print(n);
}
}
what does it show?| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Coding - 0of 0 votes
AnswersGive an array of integers, which are in repeated format except one integer, write a function to return that integer
- Ray Sun March 29, 2012 in United States for Kindle
ex[2,2,3,3,4,4,4,5,5] = 4
[2,2,2,3,3,3,3,4,4,4] = 3| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Coding - 0of 0 votes
Answerscalculate average of the values in a binary tree?
- abrar.here March 28, 2012 in United States for AWS| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 1of 1 vote
AnswersAn infinitely long stream of bits coming one bit at a time. You have to tell (at any point of time), whether the decimal number is divisible by 3 or not .
- ashish March 25, 2012 in India for bing| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Coding