Note: I have flagged this post to be changed to a community wiki because I'm unable to do so.
I have a few C# interview questions I genuinely wanted to give to our community. I was looking for option to make the question community wiki however I didn't found one.
Can an option be provided to make a new question community wiki?
Btw, the two questions are:
Question 1: Find binary tree diameter  interview problem
You have arrived to the campus and found the building. As you look at the floor plan you notice it's a very strange building, there is no corridor. The rooms are connected to each other like binary tree.
You're at an end leaf room and you have to go to another end leaf room. You're in a hurry, so of course, this is the largest path between two leaves in the tree. How many rooms are on the longest path between these two leaves in the tree?
We store set of integers in a binary search tree serialized to a file. The task is to calculate the diameter of the binary search tree. The diameter of a tree is the number of nodes on the longest path between two terminal nodes (leaves) in the tree.
Hint: The diameter of a tree T is the largest of the following quantities:
 the diameter of T's left subtree
 the diameter of T's right subtree
 the longest path between leaves that goes through the root of T (this can be computed from the heights of the subtrees of T)
Input format: The tree is printed in an ASCII file (integers are printed as charachters) with the following algorithm:
print_node node;
print_node.value;
if there is no left
print "term"
else
print_node node.left
if there is no right
print "term"
else
print_node node.right
Sample input:
5
 
3 7

9
is stored as:
5\n
3\n
TERM\n
TERM\n
7\n
TERM\n
9\n
TERM\n
TERM\n
Question 2: Decrypt the series  interview problem
In the auditorium the seats are made of pillows. One seat consists of several pillows but most of the seats are higher or lower than the optimal height. The optimal height is represented with 0. If a seat has one pillow less the optimal it's 1, if it has pillows more than it's 2.
You are given the sequence of the seats, N integers. The task is to find the number of continpus sequences of seats where you can arrange the pillows so that all seats in the sequence are at optimal height.
For example if the sequence is: 2, 2, 6, 6, 8
There are 3 such sequences
2, 2
6, 6
2, 2, 6, 6
Input format:
The first line contains a single integer N which denotes the number of integers in the array. The next N lines contains N integers which is the sequence.
Constrains:
1 <= N <=10 ^6 (do not forget that 10^6 squared is a big number, you have a big audience;) 10 <= A[i] <= 10
Output format: One line containing the number of sequences whose sum is zero.
Sample input:
5
2
2
6
6
8
Sample output:
3
Source: How to ask community wiki question?
By: http://meta.stackexchange.com/users/287137
From: StackExchange Network