Amazon Interview Question for Software Engineer / Developers






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

Me: I asked him to get into AIRPLANE and not to get down.

- Salma April 01, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Its kinda simple... actually an extension of reversing a string using stack... u only need few more checks and an additional char array...

char Rev_Vow(char *s, int i)
{
     static int j=0,k=0;
     if(s[i] != '\0')
     {
        if(s[i]=='a' || s[i]=='e' || s[i]=='i' || s[i]=='o' || s[i]=='u' )
         {
             temp[j]=s[i];
             j++;
         }
       ch = Rev_Vow(s,i+1);

         if( ch =='a' || ch =='e' || ch =='i' || ch =='o' || ch =='u' )
         {
             s[i]=t[k];
             k++;
         }
     }
      return 'y'; 
}


void main()
{
    char *str,ch;
    gets(str);
    ch=Rev_Vow(str,0);
}

- Mayank Verma April 18, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Just remove all the vowels from the i/p string and print it....
as we are not supposed to touch consonants. so when we remove vowels we are left out with consonants only...........
e Airplane ==> rpln..
Correct me if m wrong....

- kushal July 01, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

We don't even need a stack. Have two pointers, one pointing at the starting of the string (to a vowel) and other poiting to the end of the string (to another vowel). Keep swapping them until the indices of the two sides overlap.

- nanmaga October 09, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Indeed, it sounds like a modified version of in-place string reversal, except we swap only the vowels.

- mrzk August 26, 2011 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

can some one pls explain , how the last solution get us the consonants leaving vowels out from the string ( we are only trying to replace one vowel with other as per my understanding of the previous comment ) pls clarify me .

- Anonymous August 31, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

A I R P L A N E
i = 0 j = 7
swap(arr[i], arr[j]);
i++ j--

E I R P L A N A
i = 1 j = 6
as arr[i] is vowel & arr[j] is not vowel j--

and so on

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

public class RemoveVowel {
	
	public static boolean isVowel(char x){
		if( x == 'a' || x == 'A' ||
			x == 'e' || x == 'E' ||
			x == 'i' || x == 'I' ||	
			x == 'o' || x == 'O' ||
			x == 'u' || x == 'U' ){
			return true;
		}else{
			return false;
		}
	}
	
	public static String removeVowel( String s){
		StringBuilder S = new StringBuilder(s);
		int Vstart = -1;
		int Vcounter = 0;
		
		for (int i = 0; i < S.length(); i++) {
			
			if (isVowel(S.charAt(i))) {
				if( Vstart == -1 ){
					Vstart = i;
				}
				Vcounter++;
			}else if( Vstart != -1 ){
				char y = S.charAt(i);
				char z = S.charAt(Vstart);
				S.setCharAt(Vstart, y);
				S.setCharAt(i, z);
				Vstart++;
			}
		}
		
		return S.toString().substring(0,s.length() - Vcounter);
	}

	public static void main(String[] args) {
		System.out.println(removeVowel("hello everyone, this is Java program"));	
	}
}

- albertchenyu March 02, 2015 | 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