Amazon Interview Question for SDE-2s


Country: United States
Interview Type: In-Person




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

class ENewsManager {
	List<NewsChannel> subscriptionList;

	public void addSubscription(NewsChannel n) {}
	public void removeSubscription(NewsChannel n) {}
	public void searchSubscriptionList(NewsChannel n){}
	
	public void refreshNewsChannel(NewsChannel n){}
	
	
}

class NewsChannel {
	HashMap<Date, NewsContent> downloadedContent;
	List<String> topicsOfInterest;

	public void addInterest(String s) {}
	public void removeInterest(String s) {}
	public void checkForNewNewsContent(){}
	public void removeNewsContent(NewsContent n){}

	public void browseNews(Date d){
		//News sorted by date
		NewsContent n=downloadedContent.get(d /*Calendar.DATE*/);
		displayNews(n);
	}
	
	public void displayNews(NewsContent n){}

}

class NewsContent {
	String title;
	Date dateOfNews;
	String htmlNewsContent;

}

- satis June 10, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I have writtern considering only one type (Type A) of newspaper and it can exteded for other types as well. I have used builder design pattern for implementation.
My approach is like:

class newspaper
{
	public:
	string *s;
	virtual void political_news(string *s);
	virtual void sports_news(string *s);
	virtual void entertainment_news(string *s);
};

class News_Articles: public newspaper
{
	public:
	void political_news(string *s)
		return s;
	void entertainment_news(string *s)
		return s;
	void sports_news(string *s)
		return s;
};

class newspaper_type
{
	public:
	virtual void create_politicalnews();
	virtual void create_entertainmentnews();
	virtual void create_sportsnews();
};

class TypeA : public newspaper_type
{	
	public:
	void create_politicalnews()
	{
		cout<<this.political_news("type A");	
	}
	void create_sportsnews()
	{
		cout<<this.sports_news("type A");
	}
	void create_entertainmentnews()
	{
		cout<<this.entertainment_news("type A");
	}
}
class monitor
{
	private:
	newspaper_type *temp;
	public:
	monitor(newspaper_type *a)
	{
		temp=a;	
	}
	void return_news()
	{
		temp->create_politicalnews();
		temp->create_sportsnews();
		temp->create_entertainmentnews();
	}
}

- crazytanmay2245723 April 06, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class subscription {
  string name;
  string URI;
  string channel_type;
  
  TimeRange range;
  
  FeedInterval interval;
  boolean is_push;
  list<Contents> contents;
  int max_contents_entries;
  int max_contents_size;
  Interval last_read;
  
  void get_new_contents();
  // get new contents and update the contents 
};
class Monitor {
  list<subscription> s;
  int min_read_interval;
  void gather_reads(); // go over the subs and call the get_new_contens
  // if the last_interval + interval < time now. 
  // if is_push, then ignore. 
  // if range condition met, then call the remove subscriton on the news
  int min_read_interval;
  void runner(); // runs after the min_read_interval and call
  // gather reads
};

class app {
  list<subscription> sub;
  Monitor m;

  public:
  boolean get_subscription(string url); 
  // and update the monitor with the subscrition
  string list_subscritions();
  void remove_subsciption(string uri); // lok for uri in the subscritopn list
  void display_reads();      
      
};

- ali.kheam June 14, 2017 | 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