Round 4:
It was again telephonic with one of the top shots. Also the last of the marathon.
Q 1: There are two linked lists. You need to find if there is a intersection in these lists. By intersection what he meant was that if two link lists merged at some point.
Q2: After solving the above he asked me the node at which they will merge.
Q3: Given a graph , you are given a particular node and asked all the node which can be accessed from this node and all node which can access this node. (Directed graph)
Q4 : If 2nd October 2001 was a palindrome : 10022001 which date before this was palindrome?
Mail me if you find some problem solving the above.
Friday, July 14, 2006
Amazon Interview Round 4
Subscribe to:
Post Comments (Atom)
2 comments:
Q 1: There are two linked lists. You need to find if there is a intersection in these lists. By intersection what he meant was that if two link lists merged at some point.
Q2: After solving the above he asked me the node at which they will merge.
Solution A
1. Find length of first list SmallListLength
2. find length of second list. LongListLength (WLOG)
Lets call it SmallList LongList
3. Progress Long list with LongListLength - SmallListLength
4. Progress both list together,
5. display and break when both list intersects. In case of null, Declare, no intersection found.
Solution B , Using recursion, Termination condition need to pass information about which is long list, and also pass the node to the point where the actual comparison occurs.
Recommended approach seems to be A.
Q4 : If 2nd October 2001 was a palindrome : 10022001 which date before this was palindrome?
08-31-1380
Approach,
First look for days as its value more than month when placed into years.
Days have options - 01 , 11, 21, 31 i.e 10Xx,11XX,12XX,13XX years - Max = 13xx ( 31th day)
Now as we have fixed day, Month would have following option - 01, 03,04,06,08, 10,12 , maximum among these values is 80 that is 08th month (August)
Post a Comment