Recent Interview Questions
- 2of 2 votes
Answersint a ; int main() { printf("%u\n",&a);
}
- !@# September 22, 2014 in India
what will be the o/p of the above code if we run it 5 times, will it be same every time or not?| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer - 2of 2 votes
AnswersProblem Statement
- suresh August 02, 2014 in India
You have two strings A and B. Each one contains some letters and exactly one asterisk.
You have to replace the asterisk in each string with a letter sequence (possibly of zero length) so that the resulting two
strings are equal. This equal string is what you have to return. Attempt to return the shortest possible string.
The letter sequences may be same or different.
If it is not possible to make the given strings equal, return the string "not-possible".
Additional Constraints
- A and B will contain only uppercase letters and asterisks.
- A and B will contain one asterisk each.
Examples
0)
"SOCIA*TWIST"
"SOCIALTWI*T"
Returns: "SOCIALTWIST"
1)
"HELLO*"
"HI*"
Returns: "not-possible"
2)
"PROFESS*"
"*PROFESS"
Returns: "PROFESS"
3)
"*EXAMPLETEST"
"THIRDEXAMPLE*"
Returns: "THIRDEXAMPLETEST"
4)
"*TELL"
"*AFRIEND"
Returns: "not-possible"
5)
"*"
"B*"
Returns: "B"
6)
"*C"
"D*"
Returns: "DC"
program should be written in java| Report Duplicate | Flag | PURGE
A9 Applications Developer Algorithm - 2of 2 votes
AnswersI was asked to design an application that sends a message to two friends if they come within two miles of each other.
- gdg June 28, 2014 in India
I gave him a solution indicating the data structures used to maintain the friend list and model of the solution .
He pointed out the cons of the solution and I modified the data structure| Report Duplicate | Flag | PURGE
Microsoft - 2of 2 votes
AnswersHow would you maintain concurrency on a shared page being edited by multiple users simultaneously.
- chaos April 03, 2014 in United States
What if the page is being shared using a client- server mechanism. Represent the classes and explain the thread safety mechnism to avoid editing conflicts.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Threads - 2of 2 votes
AnswersAssuming your laptop is a fresh one.. It is just connected to your LAN. There is no static config available. typing "google.com". what will happen ? can someone clarify me.
- Remo March 23, 2014 in United States
what will happen if it is a PPPoE connection ?
what will happen if it is a IPoE connection ?
please explain them separately| Report Duplicate | Flag | PURGE
- 2of 2 votes
AnswersThis question was a modification of question 1 in this telephonic interview
- poorna.chandra.akp February 12, 2014 in India for digital
i/p: Binary Tree
O/p: print all the pairs along a path to leaf nodes, which don't follow BST property.
Eg:-
7
2 19
8 5 12 17
13 21
46
http://pastebin.com/raw.php?i=BqrNz9pu
o/p: (8,2), (8,7)
(13, 5) ( 13, 7)
and soo on.| Report Duplicate | Flag | PURGE
Flipkart Senior Software Development Engineer - 2of 2 votes
AnswersA graph contains one start node with no out-edges and a ending node with no in-edges. Such graph contains, say 10 million nodes. Question is how to find out effectively if two nodes are connected. The graph is a directed, unweighted and acyclic graph.
- ur2cdanger January 15, 2014 in United States
Additional Information : the graph will be queried for such connectivity queries at least a million times.
I was able to come up with building a transitive closure. But the space requirements ( O(10million * 10 million ) is huge.
2) I suggested BFS but it would be O( million * 10 million ), so that also was rejected.
Is there any other effective way ?. Practically I couldn't think of any other way.| Report Duplicate | Flag | PURGE
Software Engineer / Developer Algorithm - 2of 2 votes
AnswersSuppose I have some (lng, lat) coordinate. I also have a big list of ranges,
- Aasen November 12, 2013 in United States
[ { northeast: {lng, lat}, southwest: {lng, lat} } ... ]
How can I most efficiently determine which bucket the (lng, lat) point goes into?
Also, on a design perspective. Would it make more sense for the "list of ranges" to be on some database like mysql, monodb, or on something like memcached, redis?| Report Duplicate | Flag | PURGE
Google Software Engineer Intern - 2of 2 votes
AnswersWhat could be performance hits for searching on Local computer i.e. if you are searching computer for content what are the parameters you will consider for performance
- Anon June 27, 2013 in United States| Report Duplicate | Flag | PURGE
Apple Senior Software Development Engineer Algorithm - 2of 2 votes
AnswersQ: The New operator...how does it work, what are the steps?
- Aditya April 14, 2013 in United States
A: I just said it creates a new memory in the heap and the reference points to it. He seemed satisfied.| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Java - 2of 2 votes
AnswersDuring boot, after the BIOS performs a successful power-on-self-test, describe everything that occurs until the console is presented to the user.
- longbelly March 21, 2013 in United States| Report Duplicate | Flag | PURGE
Google Site Reliability Engineer Computer Architecture & Low Level - 2of 2 votes
Answers• Including the initial parent process, how many processes are created
- Linux :) February 23, 2013 in United States
#include <stdio.h>
#include <unistd.h>
Int main()
{
Fork(); // Fork a child Process
Fork(); // Fork another child process
Fork(); // and fork another
Return 0;
}| Report Duplicate | Flag | PURGE
Algorithm - 2of 2 votes
AnswersGiven two two integer arrays. Find the longest common subsequence.
- acoding167 May 12, 2019 in United States
eg: a =[1 5 2 6 3 7], b = [5 6 7 1 2 3]. return [1 2 3] or [5 6 7]| Report Duplicate | Flag | PURGE
Google Software Engineer - 2of 2 votes
AnswersGiven a binary tree, find the closest LEAF node to the target.
- aonecoding August 24, 2018 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer - 2of 2 votes
AnswersI was asked to design a system on a whiteboard which simulate a executor.
- Patrick July 01, 2018 in United States
This system has a method that is being triggered every second. I need to add logic to the method (i.e. run jobs).
There is also a method called job_arrived() that is called when a new job arrives.. I need to implement it as well.
I needed to implement a system which tries to run each job right when it is arrived (it has a return value that gets a success status from a black box service). if the job ran successfully that's the end of it..
if not I need to re-run it after 2 seconds (and if that fails as well - there will be no re-runs).
of course - more than one job can be accepted each second.
I was asked to describes the system (describe the classes and method) and consider the system to be large scale one (meaning.. threading is in order here..).
The answer I gave was apparently not multi threaded enough..
any idea to what I should have done?
Thanks guys| Report Duplicate | Flag | PURGE
Facebook Software Developer Java - 2of 2 votes
AnswersDropbox
- aonecoding March 21, 2018 in United States
Grid Illumination: Given an NxN grid with an array of lamp coordinates.
Each lamp provides illumination to every square on their x axis,
every square on their y axis, and every square that lies in their diagonal
(think of a Queen in chess).
Given an array of query coordinates,
determine whether that point is illuminated or not. The catch is when checking a query all lamps adjacent to, or on,…| Report Duplicate | Flag | PURGE
Dropbox Software Engineer Algorithm - 2of 2 votes
AnswersMaximum Sum of Building Speed
- uppubhai December 04, 2017 in India
You are the king of Pensville where you have 2N workers.
All workers will be grouped in association of size 2,so a total of N associations have to be formed.
The building speed of the ith worker is Ai.
To make an association, you pick up 2N workers. Let the minimum building speed between both workers be x, then the association has the resultant building speed x.
You have to print the maximum value possible of the sum of building speeds of N associations if you make the associations optimally.
Constraints
1≤N≤5∗10 ^4
1≤Ai≤10^4
Input
First line contains an integer N, representing the number of associations to be made.
Next line contains 2N space separated integers, denoting the building speeds of 2N workers.
Output
Print the maximum value possible of the sum of building speeds of all the associations.
Sample Input
2
1 3 1 2
Sample Output
3| Report Duplicate | Flag | PURGE
Practo SDE1 Algorithm - 2of 2 votes
AnswersI was given a questions during an interview which I was not able to solve, please help me in finding the solution.
Ques : - Divide the set in two partition such that both the partition has minimum difference of their sum. If we add an element to the left subset during partitioning than the value of that number will automatically increases by 1, but it will not increase by 1 if I add it to the right side. Find the minimum difference between both the subsets : -ex :- {1,2,3,4,5} leftSubset = {3,4} , rightSubset = {1,2,5} effective sum of leftSubset = 3+4+2(number of elements) effective sum of rightSubset = 1+2+5 = 8 difference of left and right = (9-8)=1 =, min difference
solution : (1,2,3} {4,5}
- himanshu.tomar05 August 21, 2017 in India| Report Duplicate | Flag | PURGE
Goldman Sachs Applications Developer Algorithm - 2of 2 votes
Answers4/5 Round at Uber
- aonecoding July 20, 2017 in United States
Coding: Given a 2D array of either '\' or '/', find out how many pieces this rectangle is divided into graphically.
For a 2X2 matrix with
/\
\/
The matrix split into 5 pieces - the diamond in middle and the four corners. Return 5 as the answer.
5/5 Round at Uber
Design Excel.| Report Duplicate | Flag | PURGE
Uber Software Engineer Algorithm - 2of 2 votes
AnswersApple On-site at Cupertino
- aonecoding May 10, 2017 in United States
Team Data Warehousing
Questions on Hadoop, Hive and Spark
I. Given a table with 1B of user ID and product IDs that the users bought, and another table with product ID mapped with product name. We are trying to find the paired products that are often purchased together by the same user, such as wine and bottle opener, chips and beer … How to find the top 100 of these co-existed pairs of products. If going with hadoop, where is the bottleneck and how to optimize?
II. Someone put distribute Random()*ID in a Hive script to prevent data skew. What would be the problem here?| Report Duplicate | Flag | PURGE
Apple SDE-3 design - 2of 2 votes
Answers-How would you design Google Analytics (there are huge number of users and we need real-time analysis report)?
- Matt Chad January 20, 2016 in United States
-How would you detect trends?| Report Duplicate | Flag | PURGE
Google Software Engineer Large Scale Computing - 2of 2 votes
AnswersDuring appraisal due to bell curve funda a manager is restricted to give promotion to only one of his team members. Three of his team members are equally competant. He wanted to select one by giving a puzzle. He called his three talented team members and blidfolded them. He placed a hat on each of their heads. Manager took off their blindfolds and gave following clues and conditions
- Durga March 28, 2015 in India
1) Each hat is either white or blue
2) There is atleast one blue hat
3) Contest is fair for all the three team members
4) Each team member can see the hat of other team members but not his.
5) The team members should not communicate to each other.
The manager declared that who ever comes up first with right answer shall be given promotion.
The most talented of his team members came up with right answer and explanation.What is the answer and the logic behind that?| Report Duplicate | Flag | PURGE
Thomson Reuters Software Engineer / Developer Puzzle - 2of 2 votes
AnswersPart 1: You are given a computer #1 with array Foo, a computer #2 with array Bar and a spare computer #3. You need to apply a function F to corresponding/matching elements of the two arrays. How would you do that?
- tested.candidate March 21, 2015 in UK
Part 2: Once you scale up, how would you balance the number of machines sorting with the machines applying the function?
Part 3: What if the master (which is distributing the work) dies and never recovers?| Report Duplicate | Flag | PURGE
Google Software Engineer Distributed Computing - 2of 2 votes
AnswersYou are given a class name Person that looks like this
interface Person { boolean moveUp(); boolean moveDown(); boolean moveRight(); boolean moveLeft(); boolean found(); }
This person is standing somewhere in a cell (like a array index) inside a grid (a 2D array) of unknown size and unknown boundaries. Only given info to you is the Person object and in this unknown size grid you have a apple in some unknown cell, you have to reach to this apple in efficient way.
The methods available in the Person object will actually move the person to that cell if method returns true.
You have to implement a method
- tazo March 11, 2015 in United Statesvoid findApple(Person person);
| Report Duplicate | Flag | PURGE
Algorithm - 2of 2 votes
AnswersCrypt Analysis problem :
- akii March 03, 2015 in United States
The Interviewer told me to implement the following interface
interface Expression {
Set<Char> getChars();
boolean eval(Map<Char, Int> m);
}
Map will contain values like
{ 'O' => 2, 'N' => 3, 'E' => 1, ... 'T' => 4 , } :
And eval function evaluates if the answer is correct or not , input will have 3 strings operand1 , operand2 and answer .
Overall the question was not complete , so I asked him again and again that I just have to verify the answer and not calculate it .
Verifying was really easy just get the values from map and convert to int . Add them and verify if the answer is correct.
Cam someone tell if my assumption is correct about the problem .
Example:
ONE
+ONE
----
TWO
231
+231
----
462
FOUR
+FOUR
-----
EIGHT
5239
+5239
-----
10478| Report Duplicate | Flag | PURGE
Palantir Technology Software Engineer Algorithm - 2of 2 votes
AnswersGiven N scientists and K black holes, each scientist can query on radius, size and temperature of a black hole, what data structure would you use?
- openhealth2014 February 01, 2015 in United States
Following queries are important.
Which scientist had queried on which black hole.
What were the queries made by that scientist.| Report Duplicate | Flag | PURGE
Amazon SDE1 Object Oriented Design - 2of 2 votes
AnswersYou have a set of N objects. Each of these objects have certain properties associated with them. A property is represented by a (key, value) pair. For example, assume you have the following two objects.
- Rahul Sharma November 23, 2014 in India
Tower:
{
(height, 100), (weight, 50),
(xposition, 25), (yposition, 36)
}
Tree:
{
(area, 100), (noofleaves, 500),
(height, 25), (yposition, 36)
}
Each object you have, will have at most 4 properties. An object will have at least 1 property. Note, from the two objects above, that it is not necessary for key in the properties to be same for all the objects. Also, it is not necessary for the key to be different.
Now, given N such objects, you wish to answer M queries. Each query is represented by a set of properties (again, at most 4 properties, and at least 1 property). The answer for the query is the number of objects in the set, that have all the given properties. Two properties are considered equal iff both the key and the value match.
For example, if you have the above two objects, then the answer for the following queries is
Query:
{ (height, 100), (yposition, 36) }
Answer:
1 // matches Tower, but not Tree
Query:
{ (yposition, 36) }
Answer:
2 // matches both Tower and Tree
Query:
{ (height, 100), (noofleaves, 500) }
Answer:
0 // neither Tower, not Tree satisfy both properties
Input
The first line of input contains N and M. This is followed by the description of the N objects. The description of the i-th object will start by a number k, which is the number of properties associated with the object. The next k lines contain two space separated strings - the property key and the property value. Note that the property value is not necessarily an integer (although this is so for the example above).
This is followed by the description of M queries. The format of a query will be exactly same to that of the objects. Check the Sample Input for clarification.
One test file will contain only one test case. A single test case may contain several queries.
Output
Print M lines. Each line must be the answer of the respective query.
Constraints
1 ≤ N ≤ 10000
1 ≤ M ≤ 100000
1 ≤ k ≤ 4
Sample Input
2 3
4
height 100a
weight 50b
xposition 25a
yposition 36b
4
area 100a
noofleaves 500
height 25
yposition 36b
3
weight 80
xposition 25a
yposition 36b
1
yposition 36b
2
xposition 25a
yposition 36b
Sample Output
0
2
1| Report Duplicate | Flag | PURGE
Directi Intern Algorithm - 2of 2 votes
AnswersDesign a Meeting Reminder Pop-up similar to one found on outlook.
- R@M3$H.N August 29, 2014 in India
Data Structure to be used and come up with classes.| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 2of 2 votes
Answershow to do this round1 question 1:
- dsAlgo August 15, 2014 in India
http://www.geeksforgeeks.org/directi-interview-set-5-campus/
A string can contain only a, b or c. There cannot be 2 consecutive same character. First and last character cannot be same. Now given a string with ‘a’, ‘b’, ‘c’ or ‘?’. We need to find the string replacing ‘?’ that satisfy the above conditions. For multiple answer display lexicographically smallest string. For no answer possible display “Not Possible”.| Report Duplicate | Flag | PURGE
Directi SDE1 - 2of 2 votes
AnswersGiven a list of stock quotes over a month of time,
- codechamp March 29, 2014 in United States for Search
Return the buy day and sell day which gives the max
profit.| Report Duplicate | Flag | PURGE
A9 Software Engineer / Developer