Greg
BAN USER- 5of 5 votes
AnswersGiven three arrays A,B,C containing unsorted numbers. Find three numbers a, b, c from each of array A, B, C such that |a-b|, |b-c| and |c-a| are minimum
- Greg in United States
Please provide as efficient code as you can.
Can you better than this ???| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays C++ Coding - 0of 0 votes
AnswersYou are given a list of items / combo_items with their price list.
- Greg in United States for Bing
And you are given list of items to buy.
Now you are asked to find which combination to buy so that it costs you minimum.
It doesnt matter if you are getting some extra items if it costs less.
Sr.No Price | Items/Combo_Items
1. 5 | Burger
2. 4 | French_Frice
3. 8 | Coldrink
4. 12 | Burger, French_Frice, Coldrink
5. 14 | Burger, Coldrink
Input Items to Buy:
Coldrink
Output(Sr.No)
3
Input Items to Buy:
Burger Coldrink
Output(Sr.No)
4
Input Items to Buy:
Burger French_Frice
Output(Sr.No)
1,2| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm
bool isBST(Node *root, int *prev)
{
if(root == NULL)
return true;
if(!isBST(root->left,prev))
return false;
if(prev >= root->data)
return false;
else
prev = root->data;
return isBST(root->right,prev);
}
int main()
{
int prev = INT_MIN
cout<<isBST(root, &prev);
}
Select user, max(log_count) from (Select count(date) AS log_count, user_id AS user from table group by user_id) ;
- Greg September 04, 2014