Amazon Interview Question for SDETs


Team: kindle
Country: India
Interview Type: In-Person




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

Without dictionary lookup, wouldn't it be impossible for this problem because we have no way of knowing whether the underscores separate a word or simply letters in a word.

For example, how would we know that "are" and "widely" are two different words? Does three underscores denote separation between two words and single underscore denote separation between two letters in a word? Anyone have thoughts on this?

- prudent_programmer February 23, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

how many underscores do we have between "ro" and "ss"? is it that the difference between a normal underscore depicting a space and the underscores separating the letters in the words different depending on the number of letters that follow the underscores? If this is not the case then do we have some kind of a dictionary for lookup?

- pxb8715@g.rit.edu February 20, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

ro & ss have 3 "_". Moverover underscore can be any number of time , it's random sequence of space followed by underscore , underscore followed by char etc, there is no dictionary for lookup as well.

- email6689 February 21, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static String reverseWords(String in) {
        StringBuilder out = new StringBuilder();

        Pattern p = Pattern.compile("(\\w+)(\\s*)");
        Matcher m = p.matcher(in);
        while(m.find()) {
            StringBuilder word = new StringBuilder(m.group(1));
            out.append(word.reverse());
            out.append(m.group(2));
        }

        return out.toString();
    }

- stevedunstan.com February 25, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "a____de___r";
String newStr = "";
for(int i=0;i<str.length();i++) {
if(i==0 && str.charAt(i)=='_') {
newStr = newStr+" ";
}
if(str.charAt(i)=='_') {
if(newStr.charAt(newStr.length()-1)!=' ') {
newStr = newStr+" ";
continue;
}else {
continue;
}

}else {
newStr = newStr+str.charAt(i);
}
}
System.out.println(newStr);

}

- Anonymous March 01, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {
		// TODO Auto-generated method stub
		String str = "a____de___r";
		String newStr = "";
		for(int i=0;i<str.length();i++) {
			if(i==0 && str.charAt(i)=='_') {
				newStr = newStr+" ";
			}
			if(str.charAt(i)=='_') {
				if(newStr.charAt(newStr.length()-1)!=' ') {
					newStr = newStr+" ";
					continue;
				}else {
					continue;
				}
				
			}else {
				newStr = newStr+str.charAt(i);
			}
		}
		System.out.println(newStr);

	}

- Raj March 01, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class StringProb:
    list = []

    def removeSpace(self, str):
            list = str.split('_')
            print (list)

            for element in list:
                if element is '':
                        list.remove(element)    
            print (list)

            str1 = ""
            for strelement in list:
                str1 = str1 + " " +strelement
            print(str1)

stringprob = StringProb()            
stringprob.removeSpace("Amazon_w_e_b_services are___widely__used_acc__ro___ss_the_worl_d")

- Anshul Chauhan June 01, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

class StringProb:
list = []

def removeSpace(self, str):
list = str.split('_')
print (list)

for element in list:
if element is '':
list.remove(element)
print (list)

str1 = ""
for strelement in list:
str1 = str1 + " " +strelement
print(str1)

stringprob = StringProb()
stringprob.removeSpace("Amazon_w_e_b_services are___widely__used_acc__ro___ss_the_worl_d")

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

make it with all single '_'s
add the length of words on both sides of a '_'
If it is greater than 5 and length of word on right side is not equal to 2 then replace '_' with ' '
else remove the '_'

String str = "Amazon_w_e_b_services are___widely__used_acc__ro___ss_the_wor_d";
		
		//remove ' ' and double and triple dashes
		str = str.replace("___" , "_");
		str = str.replace("__" , "_");
		str = str.replace(" " , "_");	
	
		String newStr = "";
		String arr [] = str.split("_");
	 
		for(int i=0; i < arr.length; i++) {
			
			String words []  = newStr.split(" ");
			int  nWord = words[words.length -1].length();
			
			if (nWord + arr[i].length() > 5 && arr[i].length() != 2)
			{
					newStr +=  " ";
			}
			newStr +=  arr[i];		
		}
		
		System.out.println(newStr);

- Fillie June 21, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def remove_space(data):
    expected_string = "Amazon web services are widely used accross the world"
    exp_str_list = expected_string.split(' ')
    data_ary = data.split('_')
    print (data_ary)
    a = ''
    new_string = ''

    for i in range(len(data_ary)):
	a += data_ary[i]
	for j in range(len(exp_str_list)):
		if exp_str_list[j] == a:
			new_string += exp_str_list[j] + ' '
			a = ''
    print(new_string)


remove_space("Amazon_w_e_b_services_are___widely__used_acc__ro___ss_the_worl_d")

- Kathiresh Muthusamy August 17, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {
remove_space("Amazon_w_e_b_services_are___widely__used_acc__ro___ss_the_worl_d");

}

public static void remove_space(String data) {
String expected_string = "Amazon web services are widely used accross the world";
String[] exp_str_list = expected_string.split(" ");
String[] data_ary = data.split("_");
String a = "";
String new_string = "";

for (int i = 0; i < data_ary.length; i++) {
a += data_ary[i];
for (int j = 0; j < exp_str_list.length; j++) {
if (exp_str_list[j].equals(a)) {
new_string += exp_str_list[j] + " ";
a = "";

}

}

}

System.out.print(new_string);
}

- Anonymous January 27, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class RemoveUnderscores {

public static void main(String[] args) {
remove_space("Amazon_w_e_b_services_are___widely__used_acc__ro___ss_the_worl_d");

}

public static void remove_space(String data) {
String expected_string = "Amazon web services are widely used accross the world";
String[] exp_str_list = expected_string.split(" ");
String[] data_ary = data.split("_");
String a = "";
String new_string = "";

for (int i = 0; i < data_ary.length; i++) {
a += data_ary[i];
for (int j = 0; j < exp_str_list.length; j++) {
if (exp_str_list[j].equals(a)) {
new_string += exp_str_list[j] + " ";
a = "";

}

}

}

System.out.print(new_string);
}

}

- rajat January 27, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class string_replace {

public static void main(String args[]) {
String Str = "Amazon_w_e_b_services are___widely__used_acc__ro___ss_the_worl_d";
String Str2 = null;
if (Str.contains("_")) {
Str2 = Str.replaceAll("_", " ");
}

System.out.println("String is: " + Str2.toString());

}
}

- Rukmee Patel February 19, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class string_replace {

	public static void main(String args[]) {
		String Str = "Amazon_w_e_b_services are___widely__used_acc__ro___ss_the_worl_d";
		String Str2 = null;
		if (Str.contains("_")) {
			Str2 = Str.replaceAll("_", " ");
		}

		System.out.println("String is: " + Str2.toString());

	}
}

- Rukmee Patel February 19, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class string_replace {

	public static void main(String args[]) {
		String Str = "Amazon_w_e_b_services are___widely__used_acc__ro___ss_the_worl_d";
		String Str2 = null;
		if (Str.contains("_")) {
			Str2 = Str.replaceAll("_", " ");
		}

		System.out.println("String is: " + Str2.toString());

	}
}

- rukmee patel February 19, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class string_replace {

public static void main(String args[]) {
String Str = "Amazon_w_e_b_services are___widely__used_acc__ro___ss_the_worl_d";
String Str2 = null;
if (Str.contains("_")) {
Str2 = Str.replaceAll("_", " ");
}

System.out.println("String is: " + Str2.toString());

}
}

- Rukmee Patel February 20, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class string_replace {

	public static void main(String args[]) {
		String Str = "Amazon_w_e_b_services are___widely__used_acc__ro___ss_the_worl_d";
		String Str2 = null;
		if (Str.contains("_")) {
			Str2 = Str.replaceAll("_", " ");
		}

		System.out.println("String is: " + Str2.toString());

	}
}

- Rukmee Patel February 20, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {

String expectedString = "Amazon web services are widely used accross the world";
String inputString = "Amazon_w_e_b_services_are___widely__used_acc__ro___ss_the_worl_d";

String[] expected = expectedString.split(" ");
String[] input = inputString.split("_");

String outputString = "";

int j=-1;

for(String i : expected) {

String temp = input[++j];

if(i.equalsIgnoreCase(temp))
outputString = outputString + " " + temp;
else{

String temp1 = "";
while(!i.equalsIgnoreCase(temp)) {
temp1 = temp;
j++;
temp1=temp1+input[j];
temp=temp1;
}
outputString = outputString + " " + temp;
}




}

System.out.println(outputString);

}

- Ramana A June 28, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

import java.util.*;
public class MyClass{
public static void main(String [] args){
String str= "\"Amazon_w_e_b_services are_widelyused_accro__ss_the_worl_d\"";
System.out.println(str);
StringBuilder sb = new StringBuilder(str);
sb.replace(7,8," ");
sb.replace(13,14," ");
sb.replace(26,27," ");
sb.replace(37,38," ");
sb.replace(47,48," ");
sb.replace(51,52," ");
sb.insert(33," ");
str=String.valueOf(sb);
System.out.println(str);
str=str.replace("_","");
str=str.replace("\"" ,"");
System.out.println(str);
}
}

- Anonymous October 09, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

import java.util.*;
public class MyClass{
    public static void main(String [] args){
        String  str= "\"Amazon_w_e_b_services are_widelyused_accro__ss_the_worl_d\"";
        System.out.println(str);
        StringBuilder sb = new StringBuilder(str);
        sb.replace(7,8," ");
        sb.replace(13,14," ");
        sb.replace(26,27," ");
        sb.replace(37,38," ");
        sb.replace(47,48," ");
        sb.replace(51,52," ");
        sb.insert(33," ");
        str=String.valueOf(sb);
        System.out.println(str);
        str=str.replace("_","");
        str=str.replace("\"" ,"");
        System.out.println(str);
    }
}

- Anonymous October 09, 2018 | 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