Monday, January 13, 2014

How to prepare for an interview - 1

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:
  • Glassdoor
  • 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. 

Problems

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.

7 comments:

  1. a very nice pack of questions here :) ...
    Did you make through the final interview and have been accepted?

    ReplyDelete
  2. Thanks, Go and check the next post, and wait for more posts this series will be very long isA ..

    About your questions yes i've made interviews with all of the companies mentioned above and each one has a story :) .. ed3ely b2ah :)

    ReplyDelete
  3. Can u explain the 6th solution in full detail?

    ReplyDelete
    Replies
    1. It resets all the elements of rows and columns that has an element equals 0

      Delete
  4. Can you please give a small test case for the 6th question? Just to make sure the question is what i think. Thanks in advance :)

    ReplyDelete
  5. I really appreciate your efforts , do share more content like this content writing courses

    ReplyDelete
  6. I found it very interesting website thank you for sharing with us free logo maker

    ReplyDelete