Vasanthakumarsharma
BAN USERStore the Name-Number pair in a Hash, with the number as key.
HashTable must be implemented in a separate chaining strategy, storing all the matching names in a list, against the key (phone number)
Store the Name-Number pair in a Hash, with the number as key.
HashTable must be implemented in a separate chaining strategy, storing all the matching names in a list, against the key (phone number)
This can be solved simply by maintaining a Min and max stock price.
Globals
int Size = 100; //Some large value
int StockStack[size];
int Min = 32767; //Some large sentinel value
int Max = -1;
int spanOfStack( int StockPriceForTheDay)
{
int count = 0;
if(StockPriceForTheDay <= Min)
{
Min = StockPriceForTheDay;
StockStack.push(Min);
return -1;
}
else if(StockPriceOfTheDay >= Max)
{
Max = StockPriceOfTheDay;
StockStack.push(Max);
return StockStack.NumberOfElements();
}
else
{
StockStack.push(StockPriceForTheDay);
for(int i=0;i<StockStack.NumberOfElements();i++)
{
if(StockStack[i]<StockPriceForTheDay)
count++;
}
return count;
}
}
Store the Name-Number pair in a Hash, with the number as key.
- Vasanthakumarsharma April 05, 2014HashTable must be implemented in a separate chaining strategy, storing all the matching names in a list, against the key (phone number)