hjain1011
BAN USERdepth of node = max( depth of node->lChild , depth of node-> rChild) +1
when it is equal to n then print value. base algo can be
int Tree::TreeDepth(treePtr root)
{
if(!root)
return 0;
else
{
int lDepth=TreeDepth(root->lChild);
int rDepth=TreeDepth(root->rChild);
int currDepth;
if(lDepth>rDepth)
currDepth = lDepth+1;
else
currDepth = rDepth+1;
if(currDepth==N)
cout <<root->value<<endl;
return currDepth;
}
}
you cant do anything for 3 just check if it is possible or not. add all digits and the sum should be devisible by 3.
for 2 and 5 ..... the number should have 0 at its units place and then take the rest numbers such that hightes close to 9 is is in the left side and so on.
Take an array of size M/2. (fast pointer slow pointer approach)Start keeping the stream into the array. Slow index is 0 and Fast index is also 0 in the start. Once fast index is incremented twice then increment slow index once. When the fast pointer reach the end of the array of size M/2(At this point slow will be at M/4). After this point we don't need to write anything just increment the slow index for every two element of the stream read. Finally you will have the slow index at the N/2 element.
- hjain1011 October 26, 2012
Use both trie and map.
- hjain1011 September 27, 2014use hash map to store mapping of word =>definition
use trie to suggest words and words close to a typed wrong word.