Software Engineer Interview Questions
- -1of 1 vote
AnswerA binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.
- Anonymous_geek April 18, 2017 in United States
For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3. The number 20 has binary representation 10100 and contains one binary gap of length 1. The number 15 has binary representation 1111 and has no binary gaps.
Write a function:
int solution(int N);
that, given a positive integer N, returns the length of its longest binary gap. The function should return 0 if N doesn't contain a binary gap.
For example, given N = 1041 the function should return 5, because N has binary representation 10000010001 and so its longest binary gap is of length 5.
Assume that:
N is an integer within the range [1..2,147,483,647].
Complexity:
expected worst-case time complexity is O(log(N));
expected worst-case space complexity is O(1).| Report Duplicate | Flag | PURGE
Software Engineer - 1of 1 vote
AnswersFind two strings are meta string or not
- ashishsaraswat.iips April 18, 2017 in India
for eg:-
Converse
Conserve
are meta strings because if we swap s and v in the string both string will become equal. If swapping of more than one pair can be done then it is not a meta string| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersFind the median of a bst in O(n) time and O(1) space
- ashishsaraswat.iips April 18, 2017 in India| Report Duplicate | Flag | PURGE
Google Software Engineer - 1of 1 vote
AnswersVMWare Standard Online Screen
- aonecoding April 18, 2017 in United States
3rd Question Given an array of strings and a long description about the formatting of IPv6 and IPv4 (it took me more than 5 minutes to read the description). Write a function to find if a string is IPv4 or IPv6 address or neither.
4th Question Given an integer array, whenever a duplicate number is found, you may increment it (++). Find the minimum sum of the numbers in the array by keep incrementing the dups until all the numbers are unique.| Report Duplicate | Flag | PURGE
VMWare Inc Software Engineer Algorithm - 2of 2 votes
AnswerVMWare Standard Online Screen
- aonecoding April 18, 2017 in United States
The Online Assessment was called something like Life Cycle Challenge-qpan.
There are 4 questions in total given 60 minutes. The problem description was unexpectedly long that it takes 5 minutes just to read a question.
1st Question Design a function to create BST. Given an integer array, insert the integers into the binary search tree and print all the steps taken.
2nd Question Given an integer, print the index of all the positions in which the binary bit is 1 in order.| Report Duplicate | Flag | PURGE
VMWare Inc Software Engineer Algorithm - 0of 0 votes
AnswersGiven a count and maxvalue, write a program to return count number of unique random integers between 0 and maxvalue.
- Ray April 17, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 7of 7 votes
AnswersFacebook Senior Engineer On-site 2017
- aonecoding April 17, 2017 in United States
1st Round
Question 1: Binary tree to doubly linked list.
Question 2: Read 4 (Given the read4 API, read an entire file)
2nd Round
Culture fit. No coding.
3rd Round
Question: System Design POI (Point of Interest. Given a point, find things within a radius).
Lunch
4th Round
Question 1: Decode way
Question 2: Random max index
5th Round
Question: System design + component-wise design on download manager| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 2 votes
AnswersFind the Lexicographic next word of the input word from a list of words
- ajay.raj April 16, 2017 in United States
Example
Words list
[Cat, dog, cow, donkey, zebra, monkey],
input
duck
output
monkey
Input
dog
output
donkey
Can you use trie to solve it?
public String findNextWord(List<String> words, String input){
}| Report Duplicate | Flag | PURGE
Google Software Engineer - 2of 2 votes
AnswersGiven a equation in the form of "3x+4y+2=-5y+2x+10", simplify the equation to be in form "y=Ax+B", and return A,B. Also allow parenthesis to be in the equation. Ex. "3y-4x+(3-(2x-3y))=10y", result is "y =0.75 - 1.5x"
- anony-mites April 16, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer - 6of 6 votes
Answers5th Round
- aonecoding April 13, 2017 in United States
Open-ended question What happens when you type a url in the browser and hit enter?
Second question Given an array of integers, print all the numbers that meet the following requirement - when the number is greater than every number on its left and smaller than every number on the right.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 4 votes
Answerinterviewed by senior engineer
- aonecoding April 13, 2017 in United States
Question Given two strings s1 and s2, combine the characters in the strings and maintain the sequence of characters
Follow-up If s1 has a length of m and s2 has a length of n, how many ways the strings could be merged. Figure out the formula F(m, n) = ?| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersGiven a list of files. Return all the unique lines from all files.
- Ray April 12, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - -4of 4 votes
AnswersFind the coordinates of the rectangle which is parallel to axis and has minimum area.
- Ray April 08, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersSuppose you have a stream of (timestamp, tag) events. You need to filter this stream (online), leaving only events with tags that haven't been already encountered in the last X seconds.
- Ray April 08, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersPeople enter and leave a room over the course of a day. Each person has a badge with a unique integer id, which is logged by the security system on enter/exit. Each log entry is an enter record (“E <id>”) or and leave record (“L <id>”) for the given badge id.
- gqian3 April 07, 2017 in United States
The room is empty at the beginning and ending of the day, and there are no other ways into or out of the room.
E: Enters the room
L: Leaves the room
Well formed log:
E 111
E 222
L 111
E 111
L 222
L 111
Question: You have a log and write a function to check is it the well formed log or not.| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersDesign a data structure to support following operation:
- Priyanka April 04, 2017 in India
Insert, delete, search and min difference
Time complexity of finding min Difference should be less than O(log n).| Report Duplicate | Flag | PURGE
Directi Software Engineer Data Structures - 1of 1 vote
AnswersGiven some email ids, and a similarity function which says whether two email ids are similar, determine all the sets of email ids that are similar to each other.
- Ray March 28, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswersYou have a string consisting of open and closed parentheses, but parentheses may be imbalanced.
- Ray March 26, 2017 in United States
Make the parentheses balanced and return the new string.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswersDesign a system which takes in latitude and longitude and returns back closest 5 locations.
- Ray March 26, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer System Design - 3of 3 votes
AnswersGiven a sorted array, find all the numbers that occur more than n/4 times.
- alisonlee659 March 24, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 2 votes
AnswersHow to randomly select a number in an array?
- aonecoding March 22, 2017 in United States
array: [15, 2, 4, 5, 1, -2, 0]
Follow-up:
Given a second array freq where freq[i] represents the occurrence of the ith number in array, how to randomly select a number in array based on the frequency.
Extra requirement:
Could you complete the selection in a single-pass(go through each array only once)?| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Algorithm - 1of 5 votes
AnswersIn school a student gets rewarded if he has an attendance record without being absent for more than once or being late for 3 times continuously.
- aonecoding March 22, 2017 in United States
Given a student's attendance record represented by a string with 3 possible characters 'L'(Late), 'A'(Absent), 'O' (On time),
check whether the student qualifies for the reward.
e.g.
@INPUT (String) "OLLAOOOLLO"
@RETURN (Boolean) False
The student does not qualify for reward because "LLA" means he was late for 3 times in a row.
@INPUT (String) "OLLOAOLLO"
@RETURN (Boolean) True
Follow-up:
If known the length of the attendance string is n, how many possible ways there is to attend school and make sure you get the reward.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersIn school a student gets rewarded if he has an attendance record without being absent for more than once or being late for 3 times continuously.
- aonecoding March 22, 2017 in United States
Given a student's attendance record represented by a string with 3 possible characters 'L'(Late), 'A'(Absent), 'O' (On time), check whether the student qualifies for the reward.
e.g.
@INPUT (String) "OLLAOOOLLO"
@RETURN (Boolean) False
The student does not qualify for reward because "LLA" means he was late for 3 times in a row.
@INPUT (String) "OLLOAOLLO"
@RETURN (Boolean) True
Follow-up:
If known the length of the attendance string is n, how many possible ways there is to attend school and make sure the student gets the reward.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 2of 2 votes
AnswersFind three non-overlap windows of size k in an int array, that together has a maximum sum
- ajay.raj March 14, 2017 in United States
of the 3k entries.
example
int[] nums = [1,2,1,2,6,7,5,1]
k = 2
output
[1,2],[2,6],[7,5]| Report Duplicate | Flag | PURGE
Google Software Engineer - 3of 3 votes
AnswersGiven:
- alvaroneirareyes March 12, 2017 in United States
a encoded to 1
b encoded to 2
....
z encoded to 26
You can translate a number to a string:
'123' can be translated to 'abc'
but also can be translated to 'aw','lc' which gives 3 total translations
'12' can be translated to 'ab' and 'l' -> 2 translations
Write a function to get the number of valid combinations from a number like '123123123'| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 0 votes
Answershow to find leaf node value from preorder sequence of BST without rebuilding the tree
- ajay.raj March 11, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer - -2of 2 votes
Answersdeleted
- ajay.raj March 10, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
Answersfor a binary tree, print the root to the leaf path, but add "_" to indicate the relative position.
example:
- ajay.raj March 10, 2017 in United StatesA / \ B C / \ / \ D E F G output _ _ A _ B D _A B _E A _C F A _ C _ _ G
| Report Duplicate | Flag | PURGE
Google Software Engineer - 1of 9 votes
AnswersQ: Weighted meeting room
Given a series of meetings, how to schedule them. Cannot attend more than a meeting at the same time. Goal is to find maximum weight subset of mutually non-overlap meetings.class Meeting: def __init__(self): self.startTime self.endTime self.weight
@concernedCoder
- aonecoding February 27, 2017 in United States
When you claim the questions as fake, provide evidence. These are no doubt questions asked in the coding interviews of the best companies and they definitely help interviewees to prepare for the interview.
Why do you have a problem with this?| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswersIf a string is matched to any filter, it is in the black list, otherwise not.
- ajay.raj February 23, 2017 in United States
Design a data structure and implement following two functions.
addFilter(filter)
isInBlackList(string)
filters are in the form of
“a*b”
“abc”
“aa*b”
having at most one star, which matches 0 or more chars.| Report Duplicate | Flag | PURGE
Amazon Software Engineer