NaMo
BAN USER
If all numbers are positive we can also use
bitset
in C++. They are very efficient in terms of memory ( consumes ~120MB for +ve numbers upto 10^9 ). For eg.
bitset <1000000000> mSet
// set the num 'th bit
mSet.set( num )
....
// while checking for common element
if(mSet.test( num )
// do something
NOTE: mSet should be declared as global variable (using heap rather than stack memory)
- NaMo March 24, 2014let our original triangle be ABC, and Point P. Consider three different triangles,
PAB PBC PCA
,,
now,
if Area(ABC) == sigma( all three )
then point is inside.
For area, you can use herons formula, and for comparison of floating point values set an epsilon value of something like 10^^-6
let our original triangle be ABC, and Point P. Consider three different triangles,
PAB PBC PCA
,,
now,
if Area(ABC) == sigma( all three )
then point is inside.
For area, you can use herons formula, and for comparison of floating point values set an epsilon value of something like 10^^-6
For answering this question, first there is need to explain what does 32 in the 32-bit denotes.
32 denotes the size of main system bus( including memory bus, io bus etc. ). Its the number of bits that can be processed in parallel. It also denotes the size of registers of the CPU. (means register can process 32 bits per cycle)
So, the 32-bit OS is the os which uses all the 32 bits(all 32 bus line) that are provided by the cpu architecture.
Edit: some more explanation
the OS which is using all 32 bits, can address 2^^32 addresses, can process 32 bits of data per clock cycle. If we are having 64bit processor we can install 32bit os on it(though it would not use hardware optimally) but if we are having 32bit processor we cant install 64bit os on it.
construct dictionary using trie with augmentation.
Instead of char key's, use numbers corresponding to combination for chars.
for eg. 2 for {a,b,c}
3 for {d,e,f} and so on till 9 {w,x,y,z}
so the first level would contain 9 nodes.
Consider a word "book" in dict.
It would be inserted in order - 2665.
create a linked list / priority queue of words corresponding to same number combination in the terminal node and display the words either randomly or based upon priority.
There can be two possible solutions to this problem
I ) Use Print Spooler of OS
II ) Design specific program to handle prints
if we follow option (I) then life is simple, just put every print request we get to spooler and OS will mange by itself ( actually its a solution to producer-consumer problem )
if we follow option (II) then we would have to design priority scheduler as mentioned by @vgeek on any basis we like whether size, time of arrival or even user can be asked for priority if two print commands are given simultaneously. This would require us to code manually the work of spooler.
I would consider it as other way round, as nothing is given about extra noun-verb dict.
Let us define
Set S = {is,am,are,had,have,has}
// I am not sure whether S contains everything we need or not
// as I am not a native English speaker
the words just before any element of S would be considered as noun
and the words just after any element of S would be considered as verb.
We have to watch for special cases of passive voice statements in which
been
is used after has/have. In that case, omit been and consider
word next to it.
Obviously these rules are not sufficient, but its just an idea of mine.
why so ??
well I think because this is how grammar for english is.
It seems more or less a NLP ( natural language processing ) problem to me.
I suggest a modification to Anonymous ans, instead maintaining a bit set/or reset we maintain a actual vector of keys while going down through preorder traversal.
If we encounter any leaf, we simply add the value at vector.size()-K to a hash. In the end we sum the values in the hash.
More precisely,
Let V be Vector
Let map<int,bool> be HashMap
Start with root of the tree.
if ( root != NULL )
1. if root != Leaf
push root->data to V
preOrder(root->left)
preOrder(root->right)
Pop from V
2. else if root == Leaf
push root->data to V
map [ V [ V.size() - K - 1 ] ] = true;
Pop from V
Now, sum all the values in the map to get desired answer :)
- NaMo June 17, 2013
nice solution dude. didnt occured to me
- NaMo June 17, 2014