## Amazon Interview Question for Data Scientists

Country: United States

Comment hidden because of low score. Click to expand.
1
of 1 vote

I would probe before answering this question first
1> What kinda database (dynamo or RDBMS)
2> What does unsold item mean? It it depend on the unaltered quantity of items after listing for a certain duration of days?

Having asked that, any approach can gives me this solution but thinking in worst case scenario, I would say.

1> Take snapshot of each database.
2> For each category,
For each item in the category
{if item.quantity(listedDate) == item.quaniity(currentDate)}
{{list.add(item) // item as unsold }}

// Algo runs over O(n) for n numbers of items

Comment hidden because of low score. Click to expand.
0
of 0 vote

Lets say there are three items . so

1.Take these three items in hashmap/dictionary(python)
2.Put unsold=1
3.Traverse through the hashmap and if the item is sold put unsold as 0
4.Repeat 3 for all the items
5.Once all the items been marked as unsold/sold traverse through the hashmap and find an entry with unsold stilll equal to 1.
6.The item is 5 is unsold so can be printed.

Comment hidden because of low score. Click to expand.
0
of 0 vote

- Let's say we have 100 Product , so we can make bool array of 100 elements
bool arr[100];
int item;
- next we add sold item first
for (int i = 0 ; i < 100 ; ++i)
{
cin >> item;
arr[item] = 1;
}
- then we make another loop printing
for (int i = 0 ; i < 100 ; ++i)
{
if (arr[i] == 0) cout << "item number" << i+1<<"is not sold";
}
Algo O(n)

Comment hidden because of low score. Click to expand.
0
of 0 vote

Select * from
Item_table
Where initial_quantity-final_quantity = 0;

Comment hidden because of low score. Click to expand.
0
of 0 vote

Select * from
Item_table
Where initial_quantity-final_quantity = 0;

Comment hidden because of low score. Click to expand.
-1
of 1 vote

.

Comment hidden because of low score. Click to expand.
-1
of 1 vote

mmmmm

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.