How do we use Hashing of characters, I have a very funny way . Have to write a Lot , This actually , is my code . Please Help me for this , everytime , needed to find this code in my pc and copy paste .
I didn’t get the motive of your code above. BUt however, as you said, you need hashing on strings. I generally do it like:
map<string,bool>exist;
string str;
for(int i=0;i<n;i++)
{
cin>>str;
exist[str]=1;
}
// now to check if any string lets say ab exists or not,
just check if exist["ab"]==1 or not
That would initialize everything to 0. @tijoforyou,As far as I know THAT wouldn’t initialize everything to zero
Because of this,I screwed once upon a time (Though my solution was correct )
@rjohari23 That is not exactly true. memset sets data per byte. You can use memset to set values in a char array (assuming 1-byte chars, of course.) But, for an int array (usually 4-bytes), memset won’t work as you expected, most of the times. Sure, it can set 0s. (In hexadecimal terms, the integers that can be set using memset are 0x0000, 0x1111, 0x2222, … 0xFFFF, if you set the parameter somevalue as 0, 1, 2, …, F, respectively.)