Amazon Interview Question for Software Engineer / Developers






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

Main Class AuctionSystem it copntains

constructor
AuctionSystem()
AuctionSystem(bidowner,product)
AuctionSystem(bidowner)
AuctionSystem(product)

AddBid Owner ArrayList
remove bidOwner

Class BidOwner

addproduct(name,type etc) //add bid
remove product //withdraw bid

void go_for_Auction(bidowner,product) or place_bid()
setMinPrize(product)
setQuantity(product)
setwinner(user)
setTimelimit(no of days)


class users //Bidders//2rd party user who wants to buy the item using bid
{
users()
setbidprize(product)//update
remove bidprize(product) //withdraw from bid
addreview(product)
seeproductinfo(product)
seeBidOwnerInfo(BidOwner)

}

Desighn pattern & Interection between them Needed

- WgpShashank April 29, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A mediator design pattern could be used here. 'AuctionSystem' class (and interface) could be the Mediator and 'Bidders' class (and interface) could be the colleagues.

1. AuctionSystem member functions -

MaintainProductList() //Basically an ArrayList or a hashMap with key as product Id and values as current bidders

AddBidders() //Add bidders to the productList bidding in a sorted order (to ease the query of topBidder) . Could use MaxHeap as well.

RemoveBidder(Bidder ID) // Remove and reheapify

UpdateBidder(Bidder ID, Long newValue) //To update the bidding value and re-organizing.

PublishBidResult(Product Id).

Optimisitc approach, all other operations can store the bidding values unsorted and whenever PublishBidResults() is called, heapify can be done to publish the top value.


2. Bidder class member functions could have

- makeBid( int Product Id, Long Value)

- Long getCurrentBidValue (int ProductId)

- rsk October 27, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-2
of 2 vote

<pre lang="" line="1" title="CodeMonkey55969" class="run-this">/* The class name doesn't have to be Main, as long as the class is not public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
String s;
while (!(s=r.readLine()).startsWith("42")) System.out.println(s);
}
}

</pre><pre title="CodeMonkey55969" input="yes">
123</pre>

- Anonymous July 12, 2011 | Flag Reply


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More