Randomness
BAN USERpublic static void main(String args[])
{
Read Tree root T
DeleteNodeInPostOrder(T)
T = null;
}
public static void DeleteNodeInPostOrder(Node T)
{
if(T == null)
return;
DeleteNodeInPostOrder(T.left);
T.Left = null;
DeleteNodeInPostOrder(T->right);
T.right = null;
}
Obviously it depends on your knowledge .
careercup.com/salary
There are two ways to do this : One is to create a HashMap of words after sorting them and then look up in the hashMap for those word whose anagrams are to be found.
The other way is to create a TRIE of all words and then look up in TRIE as follows :
1. Construct all permutations of the word.
2. Look up in TRIE.
This can be solved using DP.
- Randomness June 24, 2012Tree is too much of an over kill
- Randomness June 11, 2012Why can't you simply use a if condition like the following :
if( (N*(Log (N))) == log(K) )
Create two arrays. One based on entry time say A and the next based on exit time say B. Sort both the arrays.
When a person wants to find out how many persons are there. He just has to perform a Binary search(This Binary search returns an index which is at most greater than or equal to the given value.) The index returned from A minus the index returned from B will be the answer.
It is explained here :
http://en.wikipedia.org/wiki/Conditional_compilation
Can you explain the logic even though you consider it simple DP
- Randomness May 28, 2012
IF we can take a 8X8 array then this problem can be solved easily. Say you are given position of white king(X,Y). Now for each black piece of board check the positions it can travel to and increment all those positions by 1.
- Randomness September 13, 2012Check : If king is in check mode ? if no then return false;
else
{
1. Check if there is a 0 around king. that is a safe place. If yes then return.
2. Check if there is a place where the count is = 1. If yes you can remove that piece by cutting through king and then return false.
3. For each white piece except king check if it can be placed around the white king so that white king is covered by 0 on all sides.
}