## Coding Interview Questions

- 0of 0 votes
Given an array[0, n-1], each number of the array is positive int. Your task is adding the operators,"+","*", "(",")" (add, multiply, parenthesis) to maximize the result . The position in the array is Fixed.

For example, "2,1,1,2", you can get (2+1)*(2+1)=9.

Follow up, if the number may be negative , how to solve it ?

- 0of 0 votes
Write a function which, given two integers (a numerator and a denominator), prints the decimal representation of the rational number "numerator/denominator".

Since all rational numbers end with a repeating section, print the repeating section of digits inside parentheses; the decimal printout will be/must be

Example:

1 , 3 = 0.(3)

2 , 4 = 0.(5)

22, 7 = 3.(142857)

etc..

- 0of 0 votes
Write a program to find distinct value out of an array. If you didnt find any duplicates return a empty array.

- 0of 0 votes
If you run the same program twice, what section would be shared in the memory?

Follow up, is the text portion of memory share? Why not?

- 0of 0 votes
Write a function that accepts an n-dimension array and prints its values--For array of any dimension.

What is the layout of multi-dimensional array in the memory?

- 0of 0 votes
Given a number n, write a function that writes a Fibonacci sequence to number n.

- 0of 0 votes
It was part of a bigger question --a large piece of code.

Implement << operator. What are the differences of implementation as a member function and a non-member function

- 0of 0 votes
What does an iterator in C++ point to in case of a vector vs. list. Where would it point to if the prior links are deleted in the list? In case of a vector if it points to a specific index, where would it point to if the prior indexes are deleted?

- 0of 0 votes
What C++ data structures would you use to implement LRU cache? Show implementation.

- 0of 0 votes
How would you implement this:

`object["String for a security name"]["another string"] = another_object`

- 0of 0 votes
What are the various ways of doing IPC in Unix/Linux? How do you implement it?

- 0of 0 votes
Design a system like friend's functionality in facebook. should have all features of facebook's friends functionality. like for each person , he can have any number of friends , he will get suggestions for new firends , showing common friends if we visits any other profile . algo should be scalable , robust .

- 1of 1 vote
Find the longest words in a given list of words that can be constructed from a given list of letters.

Your solution should take as its first argument the name of a plain text file that contains one word per line.

The remaining arguments define the list of legal letters. A letter may not appear in any single word more times than it appears in the list of letters (e.g., the input letters ‘a a b c k’ can make ‘back’ and ‘cab’ but not ‘abba’).

Here's an example of how it should work:

prompt> word-maker WORD.LST w g d a s x z c y t e i o b

['azotised', 'bawdiest', 'dystocia', 'geotaxis', 'iceboats', 'oxidates', 'oxyacids', 'sweatbox', 'tideways']

Tip: Just return the longest words which match, not all.

- 2of 2 votes
Write a code to test whether string s2 is obtained by rotating the string s1 by 2 places.

e.g S1="amazon" S2="azonam" return true

S1="quality" S2="lityqua" return false

- 0of 0 votes
Write a code to find duplicate elements in array and total count of duplicate elements.

eg. arr={5,3,4,6,7,5,3,2,1}

Duplicate elements:- 5,3

Total duplicate count:- 2

- 0of 0 votes
Design a phone book such that fields are searchable with name , with number. Later enhanced teh question asking searchable with address as well.

- 11of 11 votes
Output top N positive integer in string comparison order. For example, let's say N=1000, then you need to output in string comparison order as below:

1, 10, 100, 1000, 101, 102, ... 109, 11, 110, ...

- 1of 1 vote
How to design a multi key hash map ( key count can be dynamic. if there are two keys , initiallly which can be used to find the value , keys can be increased to three as well ex: consider school structure. Intially , consider , student id is key , later , should be searchable even with key name , later with grade.

- 1of 1 vote
Design a telephone directory for large ppl (he gave example like design for India). fields will be , first name , last name , number . this should be searchable with first name , last name , number as welll.

later added more complexity like do the same for organisation where even it contains designations. so this should be searchable with designations.

- 0of 0 votes
The digits of a number come from a stream digit by digit. At any point tell whether the number formed from the digits so far is a multiple of 3

- 0of 0 votes
In Mathematics each number has one special number, which it supports, chosen as follows. It counts the number of ones in its own binary representation, and adds this count to itself to obtain the value of the number it supports. That is, if j(m) means the number of ones in the binary representation of m, then m supports m+j(m). For example, the number eight (1000 in binary) supports nine, whereas nine supports eleven.

However, in this way not all the numbers get supported; some are left without support, and we call these numbers bleak. For example since one supports two, two supports three and three supports five, there is no number less than four, which would support four, so four is bleak.

Your task is for a given number recognize if it is bleak or supported by some number.

- 0of 0 votes
Write a method that takes a given string and replaces all occurrences of one string with another string, returning the number of replaces made. For instance given the string “Microsoft” if you were to replace all occurrences of “ic” with “MSFT” the result would be “MMSFTrosoft” with a return value of 1. As part of a final solution please provide unit tests done as well as any test cases ran. Please note that you may not use String.Replace or string::replace depending upon the language you use; you must write this functionality yourself.

- 0of 0 votes
Implement a class that does string manipulation by overloading the following operators: <<, >>, = and ==. For example consider the following code:

StrShift example;

example = “Microsoft”;

printf(“\”example << 2\” results in %s\n“, example << 2);

In the above code the output would be “ftMicroso” which shows the last two characters of the string “Microsoft” rotated to the left of the string. Please note that state is maintained so two calls of example << 1 would give the same end result as calling example << 2 once. Consideration will be given to correctness, design, code readability as well as any unit testing. As part of a final solution please submit test cases you used to verify correctness in addition to any unit tests done.

- 0of 0 votes
Write a class that represents a minimal heap. The heap class should at a minimum support the following methods:

- AllocTinyHeap() which should initialize the heap with a given amount of bytes

- DeleteTinyHeap() which frees all memory associated with the heap

- TinyAlloc() which allocates a given number of bytes on the heap if there is room

- TinyFree() which frees a specific location on the heap

You may define whatever parameters are necessary for the above methods as well as write any additional methods. Overall consideration will be given to correctness, design, code readability as well as any unit testing done. As part of a final solution please submit test cases you used to verify correctness in addition to any unit tests done.

- -1of 1 vote
The boggle game - given a 2d array of characters

- 0of 0 votes
Evaluate a given mathematical expression, taking into consideration the BODMAS rule. The expression contains no brackets.

- 0of 0 votes
Serialize and deserialize a tree.

Given a tree - not necessarily a binary tree - the serialize method should create a string for the tree. The deserialize method should be able to reproduce the same tree using the string derived from the serialize method.

Basically, serialize() takes in a tree and returns a string, deserialize() takes in a string and returns the tree.

- 0of 0 votes
Given a binary tree, write a method to determine shortest distance between two nodes. A node does not have a pointer to its parent

- 0of 0 votes
Given a binary tree, write a method to determine shortest distance between two two nodes. The node does not have a pointer to its parent

- 1of 1 vote
Given a graph, write a method to check if it is bipartite