Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

Would you please mention some example if the interviewer has given you any example.

- guptasunny158 September 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

like {cat, act}, {ate, eat, tea}

- AVK September 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

So when you hash to a spot using h(f( string) )

Store this in each node:
1. f(string) ... which is the hash key
2. string ... treat this like "data"

- bigphatkdawg September 22, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Hash table.
let h( ) be your hash function.

But before you hash each string, sort it with a linear string sort, call it f( ).

So you hash like this h(f( string) ).

So all anagrams get hashed to same spot.
Make sure you store "f(string)" when you hash.

- bigphatkdawg September 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

So when you hash to a spot using h(f( string) )

Store this in each node:
1. f(string) ... which is the hash key
2. string ... treat this like "data"

- bigphatkdawg September 22, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

private String sort(String str){		
		char a[] = str.toCharArray();
		Arrays.sort(a);
		return new String(a);
	}
	
	public void que1(String str){
		StringTokenizer st = new StringTokenizer(str);
		HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
		ArrayList<String> arr = null;
		while(st.hasMoreTokens()){
			String temp = st.nextToken();
			String temp1 = sort(temp);
			if(map.containsKey(temp1)){
				arr = map.get(temp1);
				arr.add(temp);
				map.put(temp1, arr);
			}else{
				arr = new ArrayList<String>();
				arr.add(temp);
				map.put(temp1, arr);
			}
		}
		for(Map.Entry<String, ArrayList<String>> entry : map.entrySet()){
			System.out.print(entry.getKey()+" ");
			arr = entry.getValue();
			for(int i = 0; i< arr.size(); i++){
				System.out.print(arr.get(i)+" ");
			}
			System.out.print("\n");
		}
	}

- Delta September 22, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. sort each string in the array.
2. sort the entire array.
All the anagrams will be grouped together

- amber September 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I would like to extend the solution of amber by providing comparator function, that compares sorted strings, something like:

bool cmp(string & one, string & two)
{
	string oneSorted = sort(one.begin(), one.end());
	string twoSorted = sort(two.begin(), two.end());
	
	return oneSorted.compare(twoSorted) < 0;
}

Then you may just apply this comparator to sort i.e a vector of strings:

sort(v_string.begin(), v_string.end(), cmp);

- joe kidd September 23, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1) Create a HashMap<String, StringBuffer>
Start from the first word, sort it, store this sorted word into HashMap as a key and original word as a value.

2) Iterate through the sentence, take one word at a time, sort it, check sorted word is present as a key into HashMap,
If Yes, Append this new word(original unsorted) to value i.e. StirngBuffer of that key
If Not, Add new (key, value) pair into HashMap.

3) Repeate step 3 for all the unique words.

4)Once all words are checked, iterate through the HashMap and get all the values.

- tushar11289 September 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

3) Repeate step 2 for all the unique words. (correction)

- tushar11289 September 24, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

${@print(md5(acunetix_wvs_security_test))}

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

'

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

and 1=

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

' and 1=

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

\'

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

'''

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ookjk85h74

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1 OR 1=1

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1' OR '1'='1

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1'1

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

' 1 AND 1=1

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1 AND 1=1

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1\'1

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

) or ('1'='1--

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

' or 1=1/*

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

' or 1=1--

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

order by 1000/*

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

order by 1000;--

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

' order by 1000/*

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

' order by 1000;--

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

' or 1=1--

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

" or 1=1--

- Anonymous May 09, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

') or ('a'='a

- Anonymous May 09, 2014 | 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