Interviewed in March at Google (Mountain View offices) for a Software Engineer, Tools & Infrastructure (SETI) position.
About myself: recent MSCS graduate.
Here's how the day went:
Here are the questions I faced:
Round 1:
Given an array of n integers, return the result of all possible equations you can generate by adding the following operators in-between the numbers: +, -, *, /, () (for prioritization).
Similar question: https://leetcode.com/problems/different-ways-to-add-parentheses
Examples:
[4, 2]: Can generate 4 + 2 = 6, 4 - 2 = 2, 4 * 2 = 8, 4 / 2 = 2 -> Return [6,2,8,2]
[4, 2, 3]: Can generate: 4 + 2 + 3, 4 + 2 - 3, 4 + 2 * 3, 4 + 2 / 3
4 - 2 + 3, 4 - 2 - 3, 4 - 2 * 3, 4 - 2 / 3
Etc.
But we can prioritize operations as well: 4 + (2 * 3) = 10 != (4 + 2) * 3 = 18Remarks:
[4, 2], [6,2,8,2], [6,2,2,8], [8,6,2,2] etc. will be accepted,Divide by Zero errors should be handled.Hints:
[4,2,1,3], one possible equation would be 4 / ((2 - 1) / 3) = 12.Round 2:
Given a string, which may contain substrings constituted of 3 or more occurrences of the same character, return the string after removing all these substrings, including the initial ones (present in the initial string), and the ones created by removing a first substring.
Examples:
"abcdddf" -> "abcf"
"eegdhhhouweppp" -> "eegdouwe"
"aabbccdddcba" -> "aabbcccba" -> "aabbba" -> "aaa" -> ""Similar question: https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string
Round 3:
Consider a n-ary tree (i.e. each parent node has at least one children (except the leafs) and up to n).
Some children nodes may be missing, i.e. a parent node could have only n/2 children.
The order of the children nodes matters here and, referring to them with their index i, a parent node with a child at index i is different than a parent node without a child at index i.
That is, the missing children nodes can be positioned anywhere between the index 0 and n - 1, and are represented by None values innode.children.
Write a recursive, in-place function which moves all missing children (i.e. the None values) to the right of the children list, and consequently, the valid children to the left.
Don't return anything, write an in-place function.
Examples:
Suppose we consider 5-ary trees.
1 - A root node with the following list of children: [NodeA, Null, Null, NodeB, NodeC]would see its list of children changed to [NodeA, NodeB, NodeC, Null, Null].
2 - This needs to be done for every parent node in the tree which have a non-empty list of children. Hence, supposing NodeAhas the following list of children: [Null, Null, Null, Null, NodeD], this list would be thus changed to [NodeD, Null, Null, Null, Null].
Round 4:
https://leetcode.com/problems/binary-tree-maximum-path-sum
Define a path in a binary tree as a contiguous sequence of edges going from node A to node B.
The path is not oriented, i.e. it can start from a leaf, go through the root and end up at another leaf, but it cannot go through the same node twice.
Define the value of a path as the sum of the nodes' value it goes through.
Return the maximum value obtained when considering all possible paths.
Hint:
Miscellaneous remarks: