Amazon Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




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

HashSet set = new HashSet();
StringBuilder str = new StringBuilder();
while(i<string.length){
while(i<string.length&&string.charAt(i)!=' '){
str.append(string.charAt(i++));
}
set.add(str.toString());
while(i<string.length() && string.charAt(i)==' '){
i++;
}
str.delete(0,str.length());
}

- ishantagarwal1986 October 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

static void printUniqueWords(String string){
		char array[] = string.toCharArray();
		HashSet<String> hashSet = new HashSet<String>();
		int start = 0;
		for (int i = 0; i <= array.length; i++) {
			if(i == array.length || array[i] == ' '){
				hashSet.add(string.substring(start, i));
				start = i+1;
			}
		}
		for (Iterator<String> iterator = hashSet.iterator(); iterator.hasNext();) {
			String string2 = iterator.next();
			System.out.println(string2);
		}
	}

- nmc January 08, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

List<char> Split(string str)
{
List<char> l = new List<char>();

foreach (char ch in str)
{
if (l.Contains(ch) || ch == ' ')
continue;
else
l.Add(ch);
}

return l;
}

- rnishkam November 14, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

//For words which are non duplicate
eg :- "This is a string which is duplicate"
ans: this
a
string
which
duplicate

static void printUniqueWords(String string){
		List<String> list = new ArrayList<String>();
		int map[]=new int[string.length()];
		int start =0;int k =0;
		for (int i = 0; i <= string.length(); i++) {
			if(i == string.length() || string.charAt(i)== ' '){
				if((k = list.indexOf(string.substring(start, i)))!= -1)
					map[k] = 1;
				else list.add(string.substring(start, i));
				start = i+1;
			}
		}
		for (int i = 0; i < list.size(); i++) {
			if(map[i] != 1)
			System.out.println(list.get(i));
		}
	}

- nmc January 08, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

we can use a trie here ..

- upcomingnewton September 16, 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