Amazon Interview Question for Software Engineers


Country: United States
Interview Type: Phone Interview




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

public String[] anagramsEliminate(String intput[]){

ArrayList<String> listAnagram=new ArrayList<String>();
ArrayList<String> eliminatedList=new ArrayList<String>();
for(String s:intput){
//reverse it
Arrays.sort(s.toCharArray());
if(!listAnagram.contains(s)){
//not an anagram
listAnagram.add(s);
}
else{
eliminatedList.add(s);
}
}
return (String[])eliminatedList.toArray();
}
}

- undefined May 27, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For the above solutions - I believe that your result will contain the sorted strings rather than the original ones

- gshapir May 27, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

For the above solutions - I believe that your result will contain the sorted strings rather than the original ones

- gshapir May 27, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

what about the space and time complexity?Can it take O(n^2)?

- Adithya June 14, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Create a hashmap <String, List<Integer>>
2. Iterate through the array of 100 strings
3. take a string, sort the chars and add it to the hashmap, add index of the string as first entry in the list.
4. iterate over all the values of the hashmap where list size is greater than one and remove those indexes from the array

- 6a61795f July 05, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Haven't tested this:

public ArrayList<String> eliminateAnagram(String[] inputArray){
  int n = inputArray.length;
  Map<String,Boolean> isAnagram = new HasMap<String,Boolean>();
  Set<String> candidates = new Set<String>();
  Set<String> ret = new Set<String>();
  ArrayList<String> ret = new ArrayList<String>();
  for(String str : inputArray) {
    char[] ca = str.toCharArray();
    Arrays.sort(ca);
    String sorted = new String(ca);
    if(seen.contains(sorted)) {
      isAnagram[str] = true;
    }
    else { seen.add(sorted); candidates.add(str); }
  }
 
  for(String candidate : candidates) {
    if(!isAnagram[candidate])
      ret.add(candidate);
  }

  return ret;
}

- arviman August 15, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hi There,

In total awe…. So much respect and gratitude to you folks for Amazon Interview Question for Software Engineers without missing any points on the Distributed vs Parallel computing. Kudos!

I know that you may answer as already in such case that you noticed that I open case 4914182641 in support center and that I need to wait their answer. But when I opened it, I start to search such problems with overdue payments on forums. And I found that everytime people said that they not get answer from support (from 48 hours to 1 week). I'm very affraid that in my case support cannot react same as I read it from forums. And that my account can be closed. It's really little sum (approx. 8 EUR for february) and very big time of use (many years). I create domain's there and buckets. And it's very affraid to lost account such way. Can you, please, help me?

Amazon S3 provides access to reliable and inexpensive data storage infrastructure. It is designed to make web-scale computing easier by enabling you to store and retrieve any amount of data, at any time, from within Amazon EC2 or anywhere on the web.

But nice Article Mate! Great Information! Keep up the good work!

Kind Regards,
Kevin

- Kevin June 02, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

public ArrayList<String> eliminateAnagram(String[] inputArray)
	{
		ArrayList<String> anagramEliminatedList = new ArrayList();
		HashMap<String, Integer> anagramMap = new HashMap<String, Integer>();
		for(String str : inputArray)
		{
			char[] charArray = str.toCharArray();
			Arrays.sort(charArray);
			String sortedString = new String(charArray);
			if(anagramMap.containsKey(sortedString))
			{
				anagramMap.put(sortedString, anagramMap.get(sortedString) + 1);
			}
			else
			{
				anagramMap.put(sortedString, 0);
			}
		}
		
		for(Map.Entry<String, Integer> entry : anagramMap.entrySet())
		{
			if(entry.getValue() == 0)
			{
				anagramEliminatedList.add(entry.getKey());
			}
		}
		return anagramEliminatedList;
	}

- PS May 26, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

def anagram(key_list):
    ana_dict = {}
    for str in key_list:
        key_anagram = ''.join(sorted(str))
        if not ana_dict.get(key_anagram):
            ana_dict[key_anagram] = str
    
    ana_dict.values()

- Indraja.Punna June 10, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

static void eliminateAnagram(String s[]){
		ArrayList<String> s1=new ArrayList<String>();
		ArrayList<String> eli=new ArrayList<String>();
		String x;
		for(int i=0;i<s.length;i++)
		{
			char c[]=s[i].toCharArray();
			Arrays.sort(c);
			x=new String(c);
			if(!s1.contains(x))
			{
				eli.add(s[i]);
				s1.add(x);
			}else{
				continue;
			}
			
		}
		System.out.println(eli);
	}

- siva June 15, 2016 | 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