In this series of posts i will talk about How to prepare for an interview, by interview i mean (Google, Facebook, Linkedin, Amazon, Imo.im, and Pocket Gems ...) interviews.
In this series i will only talk about the technical part of interview preparation. You will find lots of interview problems which i collected from lots of references like:
- Cracking an interview book
- Hacking a Google interview handouts
In this series i will solve in each post about 10 problems, may be more or less based on the difficulty of each problem then write my own solution for each problem. To get the best out of this training you should think about each problem, code it, test it and then check my solution, In case you couldn't solve the problem feel free to read/think/test/recode/discuss my solution.
Remember you should discuss these solutions with me, and refer if there are mistakes or other good solutions.
Note: I will use C++ to solve all of the coming problems, feel free to use other programming languages.
1. Determine if a string has all unique characters.
2. Reverse a string in place.
3. Remove duplicates in a string in place.
4. Write a method to decide if two strings are anagrams or not.
5. Given an image represented by N*N matrix can you rotate it 90 degrees in place.
6. Write an algorithm such that if an element in an M*N matrix is 0, its entire row and column is set to 0.
7. Assume you have a method isSubstring which checks if one word is a substring of another string. Given two strings s1, and s2. write code to check if s2 is a rotation of s1 using only one call to isSubstring (i.e., “waterbottle” is a rotation of “erbottlewat”).
8. Write a function that (insert, remove, search, print, reverse, removeDuplicates) a linked list.
9. Write a method to delete a node in the middle of a linked list given only access to that node:
Input: The node 'c', from the linked list a->b->c->d->e
Output: Nothing is returned but the linked list becomes: a->b->d->e
10. You have two numbers represented by a linked list, where each node contains a single digit. The digits are sorted in reverse order, such that the 1's digit is at the head of the list. Write a function that adds two numbers and returns the sum as a linked list.
Input: (3 -> 1 -> 5) + (5 -> 9 -> 2)
Output: 8 -> 0 -> 8
To discuss and solve more problems please read the next post.