Amazon Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

I think this type of questions are more inclined toward your ability to "ask" and refine the requirements. For instance, I'd ask:
- Where are the numbers coming from?
- What is the range?
- What are the memory/time constraints?

If the numbers are ages or binary (just 1 an 0) this could easily be done with an array.

- Herman July 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

I agree!
The more important factor to consider here is that how are the number stored and what is the retrieval methods used. Quite possible having a cache makes is little faster.
Also, I think this question seems to be like coming up with an algo that works on multiple groups of data at a time.

- Victor July 18, 2012 | Flag
Comment hidden because of low score. Click to expand.
1
of 1 vote

Needs more clarity (see below points):
1) How much memory is available to hold the numbers (since sizeof(int) = 4 & that 1M numbers would occupy atleast 1M * 4 memory size which is pretty huge)?
2) How are the numbers provided as input? for e.g. are they read from any file(s) on disk?

- rkalyankumar July 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Is that to simple?

Hash<Integer, Integer> occurenceMap = new ...

void addNext(int i) {
  Integer counter = occurenceMap.get(i);
  if (count == null)  {
   count = 0;
  } 
  occurenceMap.put(i,++count);
}
}

- gadolin July 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

please give the running code in C++ or Java

- imrhk July 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def getCount(item_list):
    hash_map = {}
    for each in item_list:
        hash_map[each] += 1

- invincibleveer July 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class CountRepeatativeNo {
	int a[] = {1, 4, 1, 5, 2, 2, 4, 3, 4, 1};

	Map<Integer, Integer> map = new HashMap<Integer, Integer>();
	
	public void test()
	{

		for(int i = 0; i < a.length ; i++)
		{
			if(map.containsKey(a[i]))
			{
				map.put(a[i], map.get(a[i])+1 );
			}
			else
			{
				map.put(a[i], 1);
			}
		}
		
		Iterator i=map.keySet().iterator();
		Iterator j=map.keySet().iterator();
		while(i.hasNext() && j.hasNext())
		{
			System.out.println("for "+j.next()+":"+map.get(i.next()));
		}

	}
	
	public static void main(String args[])
	{
		CountRepeatativeNo h=new CountRepeatativeNo();
		h.test();
	}

}

- Anonymous July 17, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

MapReduce algo

- MapReduce October 17, 2012 | 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