Saturday, February 1, 2014

How to prepare for an interview - 7

Welcome to the seventh post in the How to prepare for an interview series. If you didn't read previous post please read it from here.

Remember you should discuss these solutions with me, and refer if there are mistakes or other good solutions.


62. Given a List structure where each node contains a Next node and optionally a pointer to another list, flatten that list.


 L1 --> L2 --> L3 --> L7 --> L8
                         L4 --> L5-->L6


L1 --> L2 --> L3 -->L4 -->L5-->L6-->L7-->L8

63. Interleave two linked lists (e.g. {1, 2, 3} & {4, 5, 6} would return {1, 4, 2, 5, 3, 6}).

64. Write a simple regular experession parser using ., *, +, ?.

65. Given a list of strings, return a list of lists, where each list consists of words that are anagrams." Example: Given ["cab", "cz", "abc", "bca", "zc"] the output should be: [ [ "abc", "bca", "cab"] , [ "zc", cz"]].

66. Given a string write a function which prints all the subsets of the string. Now make the function to return only unique solutions for example if they give you "abc" you print out {a, ab, abc, ac, b, bc, c}.

67. Method to return sqrt of a number.

68. Program "atof", which means convert a string float (e.g. "345.44E-10") to an actual float without using any existing Parse Float functions. This is not hard but gets messy.

69. Function to check if any 3 numbers sum to x.

70. Merge two sorted arrays together.

71. Given an array, remove the duplicates and return a unique array keeping the first occurrence of the duplicates and the order. [@2, @1, @3, @1, @2] --> [@2, @1, @3].

Now we finished this post, Read next post. Please share the post in case you liked it.

No comments:

Post a Comment