Recent Interview Questions
- 0of 0 votes
AnswersHow will you dynamically allocate 2D array? Use 2 malloc and then do the same thing using only 1 malloc.
- spsneo January 25, 2010| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer C - 0of 0 votes
Answersgiven an array of positive and negative integers. Find the pair of number whose sum is closer to zero.
- Anonymous January 07, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersHow many binary tree can be formed if n number are given
- Arvind August 23, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 1of 1 vote
AnswersGiven an int array and an int value. Find all pairs in array that add up to value.
- optimus July 07, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 0 votes
AnswersGiven an integer array A,
- mars1021 October 27, 2008
find the max item A[i].
A[i]=A[x]+A[y].
O(nlog(n)) or O(n^2)| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test Algorithm - -1of 0 votes
Answersyou are given an array of integers containing only 0s and 1s. you have to place all the 0s in even position and 1s in odd position and if suppose no if 0s excedd no. of 1s or vice versa then keep them untouched. Do that in ONE PASS and WITHOUT taking EXTRA MEMORY.
- Bishwajit August 21, 2007
input array:
{0 1 1 0 1 0 1 0 1 1 1 0 0 1 0 1 1 }
output array:
{0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 }| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 0of 0 votes
Answers(2nd Phone Interview)
- Rick June 11, 2007
You have a file with millions of lines of data. Only two lines are identical; the rest are all unique. Each line is so long that it may not even fit in memory. What is the most efficient solution for finding the identical lines?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven two sets, Write a function to provide the union of them. STL not allowed to be used.
- Saurav July 25, 2005
Optimise for Time and space.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Sets - 0of 0 votes
AnswersGiven
colors = ["red", "blue", "green", "yellow"];
and a string
str = "Lorem ipsum dolor sit amet";
write a function that prints each letter of the string in different colors. ex. L is red, o is blue, r is green, e is yellow, m is red, after the space, i should be blue.
- rninja2019 May 08, 2019 in United States| Report Duplicate | Flag | PURGE
Google Front-end Software Engineer - 0of 0 votes
AnswersGiven a matrix which each element can be the following:
0: not walkable
1: walkable
n: Integer > 1 and is distinct in matrix
Find the minimum number of path it takes to visit each n in ascending order starting from matrix[0][0]. Note matrix[0][0] will always be 1. Allowed moves are (up,right,down,left);
Example:input: [ [1,1,0,5] [0,1,1,4] ] Output: 5.
Starting from position (0,0) we need to visit next smallest n which is 4. Min Distance from (0,0) to (1,3) is 4.
- tnutty2k8 August 23, 2017 in United States
Starting from position (1,3) we need to visit next smallest n which is 5. Min Distance from (1,3) to (0,3) is 1.
Total Min Distance is 4 + 1 = 5
Edit:
Allowed moves are [up,right,down,left]| Report Duplicate | Flag | PURGE
Algorithm - 1of 1 vote
AnswersGiven a dictionary and an char array print all the valid words that are possible using char from the array.
- neer.1304 December 02, 2016 in United States
Ex- char[] arr = {'e','o','b', 'a','m','g', 'l'}
Dict - {"go","bat","me","eat","goal", "boy", "run"}
Print - go, me, goal.
We can pre-compute as much we want but the query time must be optimal.| Report Duplicate | Flag | PURGE
Microsoft SDE-2 Algorithm - 1of 1 vote
AnswersReturn the pivot index of the given array of numbers. The pivot index is the index where the sum of the numbers on the left is equal to the sum of the numbers on the right. Input Array {1,2,3,4,0,6}
- umesh.shaw November 11, 2016 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Arrays - 4of 4 votes
AnswersYou are given a scrambled input sentence. Each word is scrambled independently, and the results are concatenated. So:
- merlinme October 25, 2016
'hello to the world'
might become:
'elhloothtedrowl'
You have a dictionary with all words in it. Unscramble the sentence.| Report Duplicate | Flag | PURGE
Google Site Reliability Engineer String Manipulation - 4of 4 votes
AnswersGiven the root of a binary tree containing integers, print the columns of the tree in order with the nodes in each column printed top-to-bottom.
- takepwn February 26, 2016 in United StatesInput: 6 / \ 3 4 / \ \ 5 1 0 / \ / 9 2 8 \ 7 Output: 9 5 3 2 6 1 7 4 8 0 Input: 1 / \ 2 3 / \ / \ 4 5 6 7 When two nodes share the same position (e.g. 5 and 6), they may be printed in either order: Output: 4 2 1 5 6 3 7 or: 4 2 1 6 5 3 7
| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Trees and Graphs - 0of 2 votes
AnswersHow many Fibonacci numbers exists less than a given number n.Can you find a function in terms of n , to get the number of fibonacci number less than n.
- Rahul Sharma January 13, 2016 in United States
Example : n = 6
Answer: 6 as (0, 1, 1, 2, 3, 5)| Report Duplicate | Flag | PURGE
Google Software Developer Algorithm - 0of 4 votes
AnswersFind the n-th smallest multiple given a set of numbers. For example, set = {4, 6}, n = 6:
- supatroopa December 12, 2015 in United States
The sequence is:
4, 6, 8, 12, 16, 18, etc...
Answer is 18| Report Duplicate | Flag | PURGE
Google Algorithm - 2of 4 votes
AnswersYou are standing before two doors.One door leads to the heaven and the other leads to Hell but you don't know what hides behind the doors. There are two gatekeepers. You know one of them always tells the truth and the other always lies, but you don't know who is the honest one and who is the liar.
- Anand Barnwal April 30, 2015 in India
You can only ask one question to one of them in order to find the way to heaven. What is the question?| Report Duplicate | Flag | PURGE
Intuit Intern Puzzle - 0of 2 votes
AnswersWrite a program to test whether a string and all strings that can be made using the characters of that string are palindrome or not.
- umang.agrawal91 April 02, 2015 in United States
Eg:
Input Output
mmo True
yakak True
travel False
Note : Please do not use any inbuilt functions.| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Coding - 3of 3 votes
AnswersImplement stairs(N) that (collect the solutions in a list) prints all the ways to climb up a N-step-stairs
- pk March 14, 2015 in United States
where one can either take a single step or double step.
We'll use 1 to represent a single step, and 2 to represent a double step.
stairs(3)
111
12
21| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 0 votes
AnswersWrite a program that reverses a linked list without using more than O(1) storage.
- eng.ahmed.moustafa February 24, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook - 1of 1 vote
AnswersA 2-D array of 1's and 0's is given. Find the row with max 1's. The array is sorted row wise (all 0's in a row are followed by all 1's).
- Guest February 12, 2015 in India| Report Duplicate | Flag | PURGE
Microsoft - 1of 1 vote
AnswersYou have a file with 100 billion URLS, find first unique URL.
- aks January 19, 2015 in India| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 2of 2 votes
AnswersGiven an array of integers, return true if there're 3 numbers adding up to zero (repetitions are allowed)
- fatenuller January 09, 2015 in United States
{10, -2, -1, 3} -> true
{10, -2, 1} -> true -2 + 1 +1 =0| Report Duplicate | Flag | PURGE
Facebook Software Engineer Intern Algorithm - 5of 5 votes
Answersint fun() { /*write code here.*/ } int main() { int i=10; fun(); printf("%d",i); }
change the value of the i without changing code of the main function, assign 20 to i ?
- mohit sharma October 28, 2014 in India| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer C - 1of 1 vote
AnswersUse the shorest unique prefix to represent each word in the array
- sunshihaosd October 25, 2014 in United States
input: ["zebra", "dog", "duck",”dot”]
output: {zebra: z, dog: do, duck: du}
[zebra, dog, duck, dove]
{zebra:z, dog: dog, duck: du, dove: dov}
[bearcat, bear]
{bearcat: bearc, bear: ""}| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm