I was contacted by a recruiter, she asked me questions about my experience, was friendly and attentive to details. Then we set up time for a "Coding Excercise".
Coding Excercise:
1. Write a parser for a simplified regular expression
On an alphabet set [a-z], a simplified regular expression is much simpler than the normal regular expression.
It has only two meta characters: '.' and '*'.
'.' -- exact one arbitrary character match.
'*' -- zero or more arbitrary character match.
Note that it is different from the normal regular expression in that '*' is on its own and does NOT act as a decorator on the leading character, I.e. in our simplified regular expression. "*" is equivalent to ".*" in regular expression.
2. Write up an analysis on the run-time complexity of your code.
There was 1 - 1.5hour time limit. I was a bit stressed with this time line and wrote a code that was just replacing "*" with ".*" and processing the result with java String matcher. Later i realized that they probably wanted me to write an actual parser from scratch, but it was too late... Anyway , this did not get me a face-to-face interview when Amazon representatives were in Toronto, but still they gave me an opportunity with the phone interview 2 weeks later.
First phone Interview:
The interviewer was nice, she asked some questions on my experience, and some Java - related questions, then she gave me a coding exercise:
Print collection of words by groups where each group consists of words which are anagrams of each other. We talked about several approaches and she gave me a hint on sorting all words, and then it was easy to put all words in a map where each key is a sorted signature of all words in the group. So I just appended them all in one string per group, and was done. It took 1 hour. So thus I was granted a second phone interview.
Second phone interview:
Interviewer asked some questions on Java Collections Framework, then asked to do a coding excercis
e:
Print a binary tree by levels of depth
7
5 8
2 6 9
(it's pretty easy when you think calmly, but at the time I was stressed because screen on my laptop suddenly flipped upside down - it's a new Windows feature, on Ctrl-Shift-Arrow Down) and I did not know how to put it back at the time, so even though the interviewer offered me an option to write my code on paper, I did not solve the question. Alas! But later wrote to the HR who scheduled my interviews, and asked for another chance because of this "accident", and they kindly gave me another chance in 2 weeks.
Another Second Phone interview:
The same interviewer as last time, asked me to write "get (int i)" and "put(int i)" methods to operate with a queue-like collection, which can hold only 3 numbers, so when you put a new number in the end of the list, one old number must be removed, which should to be the least recent requested number by "get" method.
So if you have a list of numbers (A):
237
and the list of numbers requested by "get" method (B):
13294
the least recent requested number was "1",
but when you put new number "5" in the list A, you must have a result
375
because 2 is the least recent requested number.
I got a wrong impression at first that parameters in "get" and "put" methods are indexes, so after I wrestled about 20min with a logic, I had to clarify that those parameters were actually values, not indexes. I wrote my solution. But when we started to apply a test example, turned out I did not caught the case when some number in the middle of line A is not in the line B (was never requested). I started to think where in the code is better to apply this condition, but time was already up, so i could not finish it properly. The interview lasted 1 hour.
I still think that a developer should have a time for careful thinking about optimal solution, rather then be requested to quickly pull out from his memory all possible tasks and solutions. I still wonder what would happen if I had an extra 10 min to complete a solution. Because when you trying to come up with solution under pressure, you don't think of considering and preventing all possible scenarios - you just glad that you came up with something without logical contradictions.
So I did not get past that "Second Phone Interview", but overall I consider my experience as "positive".