Monday, April 23, 2012

Face To Face (Also, A Microsoft interview)


related posts:
the technical interview


Yay... so I passed the phone Interview, and now I'm supposed to go to the face to face interview.
At the time of these interviews (about a year ago) there were some instabilities in Egypt, which resulted in delays in my interviews, not only that, they actually got us the opportunity to have these interviews out of Egypt. So we went to Istanbul,Turkey.

We (me and my colleagues ) were flown (yay) to Istanbul, and we spent a night at a 5 star hotel (which was cool by the way), and I recorded this video when I first set foot in my hotel room.. note: if you don't know Arabic, then the video won't be of much value to you sorry

:D

Just a few note before we begin:

Although I woke up very early that morning, but I barely made it on time. Due to miscommunication between me and the taxi driver, I got around 2 miles away from where I should be :(, and for some reason , the driver refused to continue, so I left the taxi and tried to find my way.

I spent some time learning Turkish, along with some body language before the interviews, but the Turkish didn't help that well.

It was somewhat impossible where I was to find a taxi, as I was on the opposite side of where I was going, and there was no way I was gonna cross that street.

I asked some people for direction, and finally got to a sweets shop, where a young female customer who could speak some English helped translate my question to a worker at that shop.... it was a very nice situation :|

Another note I found very useful on some blog, is that the interviewing process is very exhaustive, so  I recommend  getting some energy bars, or chocolate with you to eat between interviews (it was a life savior ), also a bottle of water can be helpful, but they gave each one of us a bottle ..

Getting back to the interview:

The first interview was nice, my interviewer spent a few minutes intoducing himself, get to know me and answer any questions I asked.

He asked If I was asked the triangles question in the phone interview ,and I answered Yes.

The rest of the interview was only one question.

He asked me to implement the insert method of a sorted doubly linked list, which is somewhat not that hard, but has its tricks.

At that point, it was about 3 years since I implemented  or even used a linked list, but I looked at it while studying for the interview.

I wondered why not a normal linked list, why a doubly linked list... he didn't seem to notice, but I realized after trying to implement it that it is even easier with doubly linked lists ().

 It was just a demonstration of knowledge... he didn't insist on a particular programming language, so I choose Java.
Aside from the implementation that you can find on wikipedia the real trick was testing this method

He asked me to test it, so I started with this:
-if the list is a parameter to the function (ie void add(DLinkedList l , int x) ) we can check it it is null or not.
- since we are adding integers, then we can use extreme values of ints, to see if it causes over or under flow (don't know how, but he agreed with me)
- we can add to an empty list
- add a previously added number (it should be added, he said it is okay to have duplicates)
- if the list adds objects not primitive types, we could check if it is null.

I guess that is it.

He said that they don't just test my skills, but they also try to see if I learn through the day from my interviews. So he added some test cases:

- add several items (maybe a million) and see the performance (is it linear as it should be )
- also see when adding that many items if the memory allocated increase linearly (as it should be) or not.

That is it.. and the time was up, and I got ready for the next interview, which I'll tell you all about next post isA. stay tuned.

Wednesday, April 18, 2012

The phone Interview (A Microsoft Interview)

related posts:
the technical interview

My first technical interview was a phone interview by Microsoft.
It was a half an hour interview and about 5-7 minutes of them were non interview related.. mostly about the phone connection, as I wanted to be contacted on the land line, but my interviewer couldn't call my land line so she called me on my cell phone.

I had to take the whole interview in the balcony as there is no good signal in the house (nor in the balcony, but we managed).

The funny thing was that I was wearing a suit with no shirt :D. ( it was for my self confidence), I realized after the interview that it is hard to write code or anything (for me anyway) while wearing a suit.
So for all interviews that I've been to, I never wore a suit.

The first set of questions were about some personal information..etc, then we started the real technical interview.

I don't really remember the questions very well, nor the order of them, but I'll try to do my best :)

Before the interview started, I had my browsers tabs open on several answers to some of the questions that repeatedly appear on blogs of people who had such interviews (they would've been helpful if I could take the interview on front of my computer)


One question was: what is a stack??
I answered: a stack is a data structure, and is used for storing data in a first come last served order... it supports operations like push, pop and peek..
She interrupted me, like she got what she wanted, and it seemed that I know what I'm talking about.

She Asked: what is dead code??
I said: what is what..? dead code? I never heard that term before ..!
She Asked again: what i good code?
I answered: oohh... good code, i thought you said dead code :) .. (one of my tabs could have been helpful at that moment)..... GOOD CODE.. hmmm It seems like a well written (you don't say), well documented, well designed ... objects and variables are named with meaningful names.

She Asked another questions about a project that I did in collage with friends of mine.. what it was for, and how we implemented it..
I talked to her about the project (it solves and simulates the solutions of complex equations using several numerical methods such as the bisection method and Newton Raphson method ... etc)

One other questions she asked a testing question.... it was simple but there are several test cases that needed to be handled.

The question was: given a program that was created by a bad programmer... this program contains 3 text fields and a button. The program is intended to be used by children to learn about triangles.
The child/user would enter 3 integers in the 3 text fields and presses the button, then the program draws a triangle with the 3 sides of lengths equal to the 3 integers... how would you test that??

This is a fairly simple question, but it has several corner cases which I'll talk about ...
I answered: we can first start by entering valid values in the text fields to see if it is functioning correctly with valid input, then we can change numbers we enter... we can permute them in all text fields... we can test for invalid cases like entering floating point numbers, entering negative numbers, entering numbers that do not fit in an integer (llike 99999999999999999999999999999999999999999999)
entering non numeric characters, leaving the text fields empty, leaving some text fields empty and others not... etc.
I even used some numbers as examples at some point while answering that question.. but for my unfortunate luck I used 1,2 and 3 :(  which you cannot use to create a triangle... which gets me to one case that I forgot to test for ..... which is triangle inequality... but I remembered it 15 minutes after the interview ..... yay lucky me.

So anyway.. this is the whole this as I remember (it was a year ago).

stay tuned for more interviews in the next set of posts.......

Friday, April 13, 2012

The technical interview

I've had a fair amount of technical interviews in several companies, with different missions and different points of views in technology. I also have had a fair amount of HR interviews in some companies and non-profit organizations, and for some reason I feel like I want to share this experience with you.. 
yes, you!
So, I'll probably share some of those in the following posts, but I'll try to cut them short to keep you interested and yet enlightened.

At first... I suggest reading Cracking the Coding Interview, Fourth Edition I've read it many times (often before any technical interview :| ) and it is very insightful.

Self confidence is as important as technical knowledge. If you are not confident in yourself or your abilities to handle an interview, then you'll probably not be able to perform as good as you need to nail that interview.

Interviews are done by people... so having people skills can walk you through an interview, but you need to remember that not all people react to the same actions the same way. Wisdom is important so that you say the right things at the right time.

I remember once I was at an interview at a very prestigious organization and I nailed it.. I really did. The interviewer liked me so much, I answered most of the questions right, and the ones I didn't answer, I demonstrated an organized and structured way of thinking through it, but at the end ..... when I was just about to leave, I mean if I had left at that moment I'd have had a chance, but I tried to ask my interviewer a question (i asked this question, or questions similar to it in almost every interview I went to) and that was it.....he seemed very insulted just by the fact that I want to ask him a question and he gave me a lecture (more like a 3 minutes session ) about what to ask and what not to ask.. my rights a his rights.

As I was walking through the door I just kept saying to myself "why oh why didn't I just leave when i had the chance to??". That was one looong day.

Anyway, I'll try to write in some details the interesting interviews I've been to.

Stay tuned.


goodbye long division

So, I've not posed in a long time.... (I had a writing burnout) but I think I'm back sort-of..!
anyway.. I'm gonna talk today about LONG DIVISION.

I read a post by steve yegge (if you don't know his, then you are missing out) about learning math, and it inspired me to write this post.
I -as most people- don't remember how to do long division although I'm an Engineer, but having a calculator seems to fix it.

But let's go back in time and try to learn how to divide 2 numbers, and get a good enough precision in the results.
Division is just a continuous subtraction so you can get what I call the main number..
so iv we divide 17 / 6 we can just keep subtracting 6 from 17 and keep count of how many times we did that till we can't do it anymore, which is in this case 2, then we have a remainder of 5, and we now need to get the remainder as a decimal number (which is in this case 0.8333333333333334) so how do we do that??
well... we have ( 5 / 6 ) and we need to get that as ( x / 10 ) so it is just a matter of calculating x.
x = (5 * 10 / 6) = (50 / 6) which  can be calculated the same way as before.
Again (50 / 6) gives you a "main number" of 8 for (48) and a remainder of 2

So the result for our main problem is 2.8 plus some remainder, which we can calculate as 2 / 6, which is 0.33333333 till the end of time
So the final result is 2.8333333333333333, which is happily the same result a calculator would get you.

Another easy example ( 13 / 11 ) you get a "main number" of one, and a remainder of (2 / 11), and we now want to calculate a decimal number so we have ( 2 / 11 ) = ( x / 10),
then x = (2 * 10 / 11 ) = ( 20 / 11) which results in a "main number" of 1 and a remainder of (9 / 11)
the result for the main problem till now is 1.1 plus some remainder ( 9 / 11) which we can calculate the same way
(9 / 11) = (x / 10) which results in x = (10 * 9 / 11) = (90 / 11) with a "main number" of 8 (for 88) and  remainder if (2 / 11)
so the result for our calculation till now is 1.18 plus some remainder (2/11) which we calculated before and it seems that a pattern appears here... if we keep calculating w get (2 / 11) which will get us 0.18 plus 2/11
So the final result will be 1.181818181818181818 till the end of time.

I hope this post helps you to get a new way of how to do a division without long division, and for some strange  reason without a calculator!