Software Engineer Interview Questions
- 0of 0 votes
AnswersWrite a function that given a string would print the 'expanded' version of it.
For example a2[bc2[c]]d would print out abcccbcccd
Note:
The number before the opening and closing square brackets is the multiplier for the characters within the square brackets
Method Signature [Java]:
- btmakusha January 07, 2018 in United Statespublic String expanded(String str)
| Report Duplicate | Flag | PURGE
unknown Software Engineer - 4of 4 votes
AnswersAmazon
- aonecoding January 06, 2018 in United States
Given an ArrayList of Nodes, with each Node having an ID and a parent ID, determine whether the List is given in preorder.| Report Duplicate | Flag | PURGE
Amazon Software Engineer Algorithm - 3of 3 votes
AnswersGoogle
- aonecoding January 05, 2018 in United States
Given an array a[] and an integer k, a[i] means flower at position a[i] will blossom at day i. Find the first day that there are k slots between two blooming flowers.| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
AnswersFind the Kth most Frequent Number in an Array.
Example:arr[] = {1, 2, 3, 2, 1, 2, 2, 2, 3} k = 2 Result: 3 Because '3' is the second most occurring element.
Follow up: What if the array is extremely large?
- CodeNinja January 04, 2018 in United States for Marketplace| Report Duplicate | Flag | PURGE
Uber Software Engineer Hash Table - 2of 2 votes
AnswerTwitter
- aonecoding January 04, 2018 in United States
Create a simple stack which takes a list of elements.
Each element contains a stack operator (push, pop, inc) and a value to either push/pop or two values, n and m,
which increment the bottom n values by m.
Then print the topmost value of the stack after every operation. If the stack is empty, print "empty"| Report Duplicate | Flag | PURGE
Twitter Software Engineer Algorithm - 0of 0 votes
Answerdesign a zigzag iterator, implement the prev() and hasPrev function
- shuibizai10 December 26, 2017 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer Java - 0of 0 votes
AnswersCreate a SQL-like language parser that manipulates directories and files (The compiler/parser may be created in any other language).
To summarize, I want you to create a "file and directory manipulation language" with the following rules/syntax (you may create another commands):
CREATE DIR <path>
CREATE FILE <name> IN <path> [WITH <data>]
'WITH' insert the <data> in the file on the fly, but it's optional
GET DATA FROM <path/to/file>
Examples on how this language may be used:import FDML ex = "Hey guys" data = FDML.get('GET DATA FROM "./path/to/file"'); FDML.statement("""CREATE DIR "./imgs"; CREATE FILE "test.txt" IN "./path/to/dir""") FDML.statement('CREATE FILE "welcome.txt" IN "./path/to/dir" WITH "{}"'.format(ex)) print(data)
Or those commands can be run in a shell:
- lopogax December 15, 2017 in United States
> fdml "CREATE DIR './dir'"
> /dir was created!| Report Duplicate | Flag | PURGE
unknown Software Engineer parsing - 3of 3 votes
AnswersDropBox Dec 2017
- aonecoding December 15, 2017 in United States
Congrats to Brian landing @DropBox
Dropbox always has the most responsive HR and gives review on the interview within a week. The canteen is also one of the best in Bay Area.
Phone:
LC: game of life
What if the board is huge?
Store in disk
with bitmap
Load into memory, process and write to disk row by row
Visit AONECODE.COM for private lessons by FB, Google and Uber engineers
Our ONE TO ONE class offers
SYSTEM DESIGN Courses (highly recommended for candidates of FB, LinkedIn, Amazon, Google & Uber etc.)
ALGORITHMS (conquer DP, Greedy, Graph, Advanced Algos & Clean Coding),
latest interview questions sorted by companies,
mock interviews.
Members get hired from G, U, FB, Amazon, LinkedIn, MS and other top-tier companies after weeks of training.
Email us aonecoding@gmail.com with any questions. Thanks!
Onsite:
Round 1:
Given an array of byte and a file name, find if the array of byte is in file.
Solution: Rolling hash
Round 2:
Given an Iterator of some photo with IDs, find the top K most hit photo IDs.
Follow up: What if the input is from a stream? When iterator reaches the end, moments later new hits can be added to the iterator. Modify code for this scenario.
Lunch was great.
Then came a demo round. Discussed Dropbox Paper| Report Duplicate | Flag | PURGE
Dropbox Software Engineer - 1of 1 vote
AnswersGiven an extremely large file that contains parenthesis, how would you say that the parenthesis are balanced?
The file cannot fit in the memory. How would you process the file and how would you store the intermediate results.
Walk me through the entire algorithm.
- CodeNinja December 14, 2017 in United StatesExamples: {[()]}, {[](){}}, [] are some valid examples.
| Report Duplicate | Flag | PURGE
Google Software Engineer Stacks - 0of 2 votes
AnswersGiven a matrix of each element is the height of the location, the side of the matrix has a river height h, water diffuse matrix results,
- ajay.raj December 14, 2017 in United States
Follow up If there is a place where there is not drowning a person and a dog, people want to reach the dog's position without water, the river is highly uncertain,
Ask the maximum height h such that the number of steps taken by a person is less than or equal to a given k. Traverse the height h,| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersConsider there is a streaming service, which outputs Log object to your service. The Log object has fields like {timeStamp, userId, hashtag(used in the tweet), @userAddressUsedInTweet} etc. Imagine this streaming service has very high QPS. Design your service in such a way that it can output top K userId's within a configurable time window(example: last 1 hour, last 24 hour etc). This service should be extendable to get any top K category (Example: TopK userId's, TopK hashtags etc). What would you use to design such a service. Top K is defined by its frequency, example: 1,2,3,4,1,2,1,2,1,1,5 are the userIDs then the top 2 users are userId 1 and 2.
- lks December 08, 2017 in United States
@EdgeCase:
1. Take into consideration how to store data in that window to get the topK user's.
2. The service should be highly available and should return the results quickly
3. Design and implement this service| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersC * R 2-D array, there are R, G, B, Y four types of elements, if no vertical and horizontal has three adjacent elements are the same type, then the 2-D array is valid
- ajay.raj December 07, 2017 in United States
Let write a function to determine whether a 2-D array is valid.
follow-up how to generate such a valid 2-D array| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
Answers
- ajay.raj December 06, 2017 in United StatesGive an Node { Node getLeft (); Node getRight (); String toString (); } Give a root node Node root * / \ + - / \ / \ 1 2 3 4 Return (1 + 2) * (3-4) If (1 + 2) + (3 + 4) does not need to be bracketed Only leaf nodes are numbers followup Give you * + 12-34 to return this tree
| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswerI have applied for Software Engineer at a startup company in India, I have asked the following question.
- s.lokesh1729 December 04, 2017 in India for Engineering
You are building an application with ORM model say django, you have set of models, urls. Let's say an user is hitting api /user/account/profile/xxx/yyy like this. You have to check whether user has permission to access or not. If user has access to /user/ then he has access to the whole URL, like wise if he has access to /user/account/ he has access to whole URL. User table looks like below and it has a field called prefix which contains URL prefix of that particular user.
Users
userid | prefix | username | firstname | lastname
1 /user/ lokesh1729 lokesh sanapalli
2 /user/account lokesh1729 lokesh sanapalli
What is the most efficient way to check if a particular user has access to an API or not???
I gave a brute-force approach that first we will check if he has access to /user/ then /user/account then /user/account/profile and so on, if he has access to a prefix and we will process the request.
He is not satisfied with the answer. Can anyone tell me what might be the answer for this???| Report Duplicate | Flag | PURGE
unknown Software Engineer design - 0of 0 votes
AnswersLets say we have to find a tallest line of the horizon from a given 2D array of the preprocessed image. The line starts at left most column of the Martrix and end at right most column of the matrix. To calculate the line you can only move left to right to 3 position, diagonally up , horizontally right and diagonally right i.e from a[i][j] you can move to a[i-1][j+1], a[i][j+1] and a[i+1][j+1].
- sachin323 December 02, 2017 in United States
When moving to the right we need to pick the highest value in the cell . We will do this for very row in column 0 i.e a[0][j] then we will pick the smallest value of the path we have got. The ans will the smallest of the all values we got from traversing all the path
I know this bit vague and I had hard time understanding the question but this what I understood
Lets say we have 3*3 array {{5,4,8}, {1,5,9}, {2,6,10}} . Now if we start from a[1][0] the possible path we can have
1 -> 6 -> 10 as we have to pick the highest value . Once we have this path we pick the smallest value on this path which is 1 . We repeat this for all rows in a[i][0] then among all those values pick the smallest one
Find the best line from the matrix.
I said we can do BFS to find best path but interviewer said time complexity of that is too high, need to do better than that.
Time complexity for BFS I think is Rows * 3^Colms as from any given cell we have 3 options to go to right (please confirm this as I not sure about it)| Report Duplicate | Flag | PURGE
Dropbox Software Engineer Algorithm - 3of 3 votes
AnswersCongrats on aonecode.com member V.S. on the offer from Microsoft and thanks for sharing with us the experience.
- aonecoding December 02, 2017 in United States
Coding Question 1 - Find all the paths between two nodes
Coding question 2 : Max sum in adjacent sub array
Design Question - Design a ticketing System
Design Question 2 - Design a system which allows multiple agents to read different data from same tables. Latency should be low. Algorithm should rank agents through some logic and assigned work according to that so that each agents are reading different set of rows from same table. Scale it for 20 million active agents .
Follow up - If Data Sharding is allowed, what will be the Shard Id and how the partition will look like? How your system will respond if there are agents which are also writing at same time. Consistency should be given high preference over availability.
Looking for coaching on interview prep?
Visit AONECODE.COM for ONE-TO-ONE private lessons by FB, Google and Uber engineers!
Customized course covers
System Design (for candidates of FB, LinkedIn, AMZ, Google & Uber etc)
Algorithms (DP, Greedy, Graph etc. every aspect you need in a coding interview & Clean Coding)
Interview questions sorted by companies
Mock Interviews
Our members got into G, U, FB, Amazon, LinkedIn, MS and other top-tier companies after weeks of training.
Feel free to email us aonecoding@gmail.com with any questions. Thanks!| Report Duplicate | Flag | PURGE
Microsoft Software Engineer Algorithm - 1of 1 vote
AnswersA city bus station information, example, bus No. 1 stops at abcd station, bus No. 2 stops at cefg station. Then a-d you only need to take No. 1, thus return 1, a-g is 2, because you need to transfer at station c,
- ajay.raj December 01, 2017 in United States
ask for a minimum bus you need to take to reach to another station. You can design any data structures.| Report Duplicate | Flag | PURGE
Google Software Engineer - 3of 3 votes
AnswersGiven a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature.
- md.lisul.islam November 22, 2017 in United States
[73, 74, 75, 71, 70, 76, 72] -> [1, 1, 3, 2, 1, nothing, nothing]| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 0of 0 votes
AnswersWrite code to find unmatched parentheses and return it in the below format:
- 1080ti November 18, 2017 in United States
((a) -> -10a1
(a)) -> 0a1-1
(((abc))((d))))) -> 000abc1100d111-1-1| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 1 vote
AnswersGiven an array of sorted integers and find the closest value to the given number. Array may contain duplicate values and negative numbers.
- Vijay November 17, 2017 in India
Example : Array : 2,5,6,7,8,8,9
Target number : 5
Output : 5
Target number : 11
Output : 9
Target Number : 4
Output : 5| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm Arrays Coding Data Structures - 0of 0 votes
AnswersImplement a trie tree which can add and search word, an extra "*" sign will also be considered, similar to Leetcode 211 but with "*"
- Aamir November 09, 2017 in United States
'*' means any sequence of characters (including the empty sequence).| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 2of 4 votes
AnswerCongrats to aonecode's member F.L.
- aonecoding November 03, 2017 in United States
Got offers from - Youtube(G), LinkedIn, Airbnb, Square, Wish, Blend and NextDoor!
Thanks for sharing the interview experience with us.
Youtube Interview
- Phone: Find anagrams of string A from string B (sliding window)
- Phone: Find if two frames in a screen are equal. Frames may overlap. (equal method)
Onsite:
- LC41 first missing positive
- LC499+LC505 The maze
- LC161 one edit distance
- Similar to hangman but make guesses based on a dictionary.
Assume a dictionary has words - {house, morse, jesus} and ‘morse’ is the answer. If your first guess is ‘house’, output will be ‘_o_se’, which indicates 3 letters are correct. (Here the arrangement of letters does not matter. Your guess can be ‘co’ and if answer is ‘ok’ then the output is gonna be ‘_o’ which indicates letter ‘o’ in answer. )
Try to get the answer with minimum guesses.
(Interviewer expects pre-processing the dictionary. Key: letter; Value: frequency. Begin with combinations of most frequent letters first)| Report Duplicate | Flag | PURGE
Google Software Engineer Algorithm - 1of 3 votes
AnswerCongrats to F.L.
- aonecoding November 03, 2017 in United States
Got offers from - Youtube(G), LinkedIn, Airbnb, Square, Wish, Blend and NextDoor!
Thanks for sharing the interview experience with us.
LinkedIn
Phone:
- Questions from LC tagged LinkedIn.
Onsite:
- Get sqrt(x). Output a floored integer if result is not a perfect square. sqrt(18) = 4
- Implement BST, insert, delete, search.
- Design a dashboard for service logs stats (sort and aggregate). Scale from 1 to more machines. Discuss async and realtime as different scenarios.| Report Duplicate | Flag | PURGE
Linkedin Software Engineer Algorithm - 2of 2 votes
AnswerFacebook
- aonecoding November 03, 2017 in United States
-Phone: LC304 & longest arithmetic sequence. Return the sequence.| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
AnswersGiven a string S(a data structure) that contains only square brackets, convert it to an array that stores arrays in the following format: [positionOpeningBracket, positionClosingBracket, nestedDataStructure]. Example: https://i.imgur.com/vZhlZdr.png
- lopogax October 29, 2017 in United Statesdef parser(S): #whatever... print(r) parser("[[]][]") #output: [[0,3,[1,2,null]], [4, 5, null]]
| Report Duplicate | Flag | PURGE
unknown Software Engineer Problem Solving - 3of 3 votes
AnswersQuestion 1.
- anonymous October 24, 2017 in India
You are given a string composed of uppercase English letters (‘A’ through ‘Z’).
Set of letters (‘A’, ‘E’, ‘I’, ‘O’, ‘U’) are called vowels. Other letters are called consonants.
We define foo value of a string as number of pairs of exactly same consecutive vowel letters.
For example,
Ex.1: BCDEEIOU - This has a foo value of 1 (because of EE). Note that although I is next to E, and O is next to I, and U is next to O, they aren’t exactly same neighbours, so they don’t contribute to foo value
Ex.2: BCDEEEIOU - This has foo value of 2. Because of first pair of EE and immediately next pair of EE
Ex.3: ABCDEFG - This has foo value of 0. There are no consecutive vowels
Ex.4: ABEUUOUOO - This has foo value of 2, because of UU and OO
You are given 2 inputs, N and K.
How many strings of length N can you form such that they all have foo value of K?
Let’s assume the constraints as:
1<=N<=15
0<=K<N| Report Duplicate | Flag | PURGE
Google Software Engineer - 0of 0 votes
AnswersGiven a sorted list of integers, square the elements and give the output in sorted order.
- nra October 19, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer - 0of 0 votes
AnswersFind the distance between the farthest two elements in a binary tree.
- nra October 19, 2017 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer Algorithm - 0of 0 votes
Answers
- Anonymous October 13, 2017 in United States for SeattleA text file contains {candidateID,voterID} details of an ongoing voting. Read this file in real time and report top 5 candidates. Also report a fraud if a Voter tries to vote twice or try to vote more then one candidate. Assume that the database is offline.
| Report Duplicate | Flag | PURGE
Uber Software Engineer Algorithm - 0of 0 votes
AnswersGiven list of line segments({x_start, y_start}, {x_end, y_end}) find out the maximum number of points they intersect. (interviewer said, he can make it simpler by assuming only vertical or horizontal lines with no overlapping lines)
- bottomcoder October 13, 2017 in United States
Givenen tree in which each node has (or grows) exactly 4 children with values (2, 2.5, 8, 50) plus the value of its parent node. Find out the least K values.
e,g, k = 5, node with value 2, 2.5, 4, 4.5, 6| Report Duplicate | Flag | PURGE
Microsoft Software Engineer