Software Engineer / Developer Interview Questions
- 1of 3 votes
AnswersRound 4
- sonesh July 12, 2015 in United States
Question 4 : You are given following input
Input{userId, LoginTime}
You have ping output in following way
Output(UserId, LoginTime, SessionId).
Note that the session Id is an integer, and when a user login after 30 minutes of its previous login, you will give him/her next sessonid.
new user, will always get next sessionId.
Example
Input
1 9:00 AM
2 9:10 AM
1 9:25 AM
30 12:34PM
23 3:09 PM
Output
UserId LoginTime SessionId
1 9:00 AM 1
2 9:10 AM 2
1 9:25 AM 1
30 12:34PM 3
23 3:09 PM 4
You have to do it in either SQL/Scope. You also have to minimise the complexity.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer SQL - 1of 3 votes
AnswersFind the shortest path in a maze (from origin to destination). I believe we are supposed to use Dijkstra or BFS. But what I am confused with is that Dijkstra computes the shortest path based on the distance of each edge. But a maze doesn't have weighted edges, and its shortest path should be 'minimum number of cells'. How can we make use of Dijkstra, or BFS?
- Guy January 21, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 3 votes
AnswersPower set P(S) of a set S is the set of all subsets of S. For example S = {a, b, c} then P(s) = {{}, {a}, {b}, {c}, {a,b}, {a, c}, {b, c}, {a, b, c}}.
If S has n elements in it then P(s) will have 2^n elements
- 4661 July 12, 2014 in United Statespublic List<List<int>> ComputePowerSet(int[] nums) { List<List<int>> powerSet = new List<List<int>>(); if (nums == null) return powerSet; bool[] bits = new bool[nums.Length]; bool overFlowBit = false; while (!overFlowBit) { List<int> lst = new List<int>(); for (int i = 0; i < nums.Length; i++) { if (bits[i]) lst.Add(nums[i]); } //function PlusOne returns false if the end is reached i.e. 2^n if (!PlusOne(bits)) overFlowBit = true; powerSet.Add(lst); } return powerSet; } public bool PlusOne(bool[] bits) { bool carry = true; //add i i.e. true to the bits int i = bits.Length-1; while (i >= 0 && carry) { bool b = bits[i]; bits[i] = b ^ carry; carry = b & carry; i--; } //if carry is true implies reached the end i.e. 1111 + 1 = 0000, carry = 1 return !carry; }
| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 1of 3 votes
AnswersFind top K(1000) strings that occur frequently from a file having some billions of strings.
- Boyer Moor February 20, 2014 in United States| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer - 1of 3 votes
AnswersGiven an array, you should start at index 0, and you can jump
- codechamp March 27, 2014 in United States
from the current index to a max of " current index + arr[current index]
and make it out of the array at the other end in minimum number of hops.| Report Duplicate | Flag | PURGE
Zynga Software Engineer / Developer Algorithm - 1of 3 votes
AnswersA Multi-threaded server application stops working and the last log message from the application is:
"Some Server Related Message..."
Code looks like:
CalledFunc () { Code ... Acquiring Thread lock Line printing "Some Server Related Message..." Func(); Releasing Thread Lock }
1. What should the programmer in charge do to debug this?
- joe.wynton October 07, 2014 in United States for Trading System
2. What has happened wrong in the Func()?
3. If an exception is thrown in the Func() what should be done to fix problem ?| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C# C C++ Threads - 1of 3 votes
AnswersGive a function
- mabid.mahmood July 15, 2014 in United States
getRandomTripplet()
which returns a random triplet of letters from a string. You don't know the string using calls to this function you have to correctly guess the string. the length of the string is also given.
Lets say the string is helloworld the function getRandomTriplet will return things like
hlo
hew
wld
owo
the function maintains the relative order of the letters. so it will never return
ohl since h is before o in the string.
owe since w is after e
The string is not known you are only given length of the string.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 1of 3 votes
Answershow would you store and find the top 10 queries in google from some day (when you begin to count) till a certain date?
- adam2008 February 11, 2013 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 1of 3 votes
AnswersWhat is mean by non blocking thread safe? Is it different from thread safe blokcing? Code a non blocking thread safe queue in Java
- Madan January 13, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 1of 1 vote
AnswersPush all the zero's of a given array to the end of the array. In place only. Ex 1,2,0,4,0,0,8 becomes 1,2,4,8,0,0,0
- CheckThisResume.com March 09, 2012 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm Arrays C Coding - 1of 1 vote
AnswersYou are given an array ' containing 0s and 1s. Find O(n) time and O(1) space
- Anonymous August 25, 2010
algorithm to find the maximum sub sequence which has equal number of 1s and
0s.
Examples
1) 10101010
The longest sub sequence that satisfies the problem is the input itself
2)1101000
The longest sub sequence that satisfies the problem is 110100| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 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 - 1of 1 vote
AnswersGiven an integer array, sort the integer array such that the concatenated integer of the result array is max. e.g. [4, 94, 9, 14, 1] will be sorted to [9,94,4,14,1] where the result integer is 9944141
- Anonymous February 18, 2011| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays - 1of 1 vote
AnswersYou are given two numbers in the form of linked list.Add them without reversing the linked lists. linked lists can be of any length.
- manjunath426jc December 26, 2011 in India
Ex:123 1->2->3
10234 1->0->2->3->4
ans: 10357 1->0->3->5->7| Report Duplicate | Flag | PURGE
Amazon Qualcomm Software Engineer / Developer Linked Lists - 1of 1 vote
AnswersConsider a series in which 8 teams are participating. each team plays twice with all other teams. 4 of them will go to the semi final.How many matches should a team win, so that it will ensure that it will go to semi finals.?
- putta.sreenivas May 11, 2011| Report Duplicate | Flag | PURGE
Amazon Google Developer Program Engineer Software Engineer / Developer Algorithm Brain Teasers - 1of 1 vote
AnswersWith a linked list data structure, find if a given string is palindrome or not.
- sathish.leo May 26, 2012 in United States| Report Duplicate | Flag | PURGE
Expedia Amazon Software Engineer / Developer Linked Lists - 1of 1 vote
AnswersYou are a hunter in the forest. A monkey is in the trees, but you don't know where and you can't see it. You can shoot at the trees, you have unlimited ammunition. Immediately after you shoot at a tree, if the monkey was in the tree, he falls and you win. If the monkey was not in the tree, he jumps (randomly) to an adjacent tree (he has to).
- Glude August 03, 2012 in United States
Find an algorithm to get the monkey in the fewest shots possible.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 1of 1 vote
AnswersFind the first non-repeating character in a stream of characters?
- samotgun November 18, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 Hash Table Software Engineer / Developer Algorithm - 1of 1 vote
AnswersString getSentence(String text, Set<String> dictionary);
- Vincent October 29, 2012 in United States
// text is a string without spaces, you need to insert spaces into text, so each word seperated by the space in the resulting string exists in the dictionary, return the resulting string
// running time has to be at least as good as O(n)
// getSentence("iamastudentfromwaterloo", {"from, "waterloo", "hi", "am", "yes", "i", "a", "student"}) -> "i am a student from waterloo"| Report Duplicate | Flag | PURGE
Twitter Google Software Engineer / Developer Software Engineer in Test Algorithm - 1of 1 vote
AnswersYou are given a huge log file which holds the entry and exit time of each person entering and exiting the office on a given day
- evolution monkey June 03, 2012 in United States
format of file:
entry time exit time
09:12:23 11:14:35
10:34:01 13:23:40
10:34:31 11:20:10
.
.upto N entries for a given day
Design a function which returns the total number of persons in the office at any given time. e.g input to function is 11:05:20.
The interviewer said he could call the function every second with input 11:05:20, 11:05:21,11:05:22, 11:05:23..........14:30:30
I really did not understand how to optimize the function.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersFind if a binary tree is bst
- anonym October 10, 2011 in -| Report Duplicate | Flag | PURGE
Amazon Flipkart Groupon Software Engineer / Developer Trees and Graphs - 1of 1 vote
AnswersGiven preorder traversal array of a BST, recontruct the BST.
- jiangok2006 July 26, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Coding - 1of 1 vote
Answers1. A
- amklo December 30, 2010
2. Ctrl+A
3. Ctrl+C
4. Ctrl+V
If you can only press the keyboard for N times (with the above four keys), please write a program to produce maximum numbers of A. If possible, please also print out the sequence of keys.
So the input parameter is N (No. of keys that you can press), the output is M (No. of As that you can produce).| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersThere is a given linked list where each node can consist of any number of characters :- For example
- vibsy October 25, 2012 in India
a-->bcd-->ef-->g-->f-->ed-->c-->ba.
Now please write a function where the linked list will return true if it is a palindrome .
Like in above example the linked list should return true| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Software Engineer in Test Data Structures - 1of 1 vote
Answershow to find a duplicate element in an array without using extra memory....do this in O(n)?
- vineetsetia009 November 20, 2011 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 1of 1 vote
Answers* You are given 2 eggs.
- dareyouspam May 06, 2012 in United States
* You have access to a 100-storey building.
* Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical.
* You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking.
* Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process.| Report Duplicate | Flag | PURGE
NVIDIA Morgan Stanley Software Engineer / Developer Brain Teasers Algorithm - 1of 1 vote
AnswersGiven a dictionary of strings [ strings are in sorted order] you have to find the precedence of characters according to the dictionary..
- Anton April 21, 2012 in India
eat
bxy
e is ranked above b according to the dictionary.| Report Duplicate | Flag | PURGE
Google Amazon Software Engineer / Developer Algorithm Data Structures Trees and Graphs Brain Teasers - 1of 1 vote
AnswersCelebrity problem:
- sreemana@buffalo.edu March 26, 2012 in United States
You have a room with n people. A celebrity walks in. Everyone knows the celebrity, the celebrity knows no one. Non-celebrities may/may not know anyone in the room. Give an algorithm to find the celebrity. Discuss the complexity.| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Algorithm - 1of 1 vote
Answersthere is a pyramid with 1 cup at level , 2 at level 2 , 3 at level 3 and so on..
- anonymous July 14, 2011 in United States
It looks something like this
1
2 3
4 5 6
every cup has capacity C. you pour L liters of water from top . when cup 1 gets filled , it overflows to cup 2,3 equally, and when they get filled , Cup 4 and 6 get water only from 2 and 3 resp but 5 gets water from both the cups and so on.
Now given C and M .Find the amount of water in ith cup.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Dynamic Programming - 1of 1 vote
AnswersGiven a string with multiple spaces write a function to in-place trim all spaces leaving a single space between words
- employee11 June 09, 2014 in Israel
e.g.
_ _ _ Hello _ _ _ World _ _ _
Hello _ World _ _ _ _ _ _ _ _ _| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm