Amazon Interview Question for Quality Assurance Engineers


Country: United States
Interview Type: Phone Interview




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

1. f (string, strong) // happy path
2. f (null, null) // both null
3. f ("", "") // both empty strings
4. f (" ", " ") // both empty strings with spaces - blank strings
5. f ("abc", "zxy") // no matches
6. f ("!@#$", "1@#!@") // special chars
7. f (null, "somestring") // 1st param null other not
8. f ("somestring", null) // 2nd param null other not
9. Test with very large inputs
10. f ("azzzzzzzz", "zzzzzzza") // mathcing in different positions

In general terms these are some sample test cases to begin with, but
other tests that could be included as necessary.

- guilhebl May 04, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import java.util.HashSet;
import java.util.Set;


public class Test {

public static void main(String[] args) {

String x ="String";
String y = "strong";
Set<Character> set = new HashSet<Character>();
for (int i = 0; i < x.length(); i++) {
if(y.indexOf(x.charAt(i))!=-1){
set.add(x.charAt(i));
}
}
char[] xxx = new char[set.size()];
int i =0;
for (char xx : set) {
xxx[i] = xx;
i++;
}
String xxxx = new String(xxx);
System.out.println(xxxx);

}

}

- Vipul Agarwal May 07, 2017 | 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 x ="String";
String y = "Strong";
Set<Character> set = new LinkedHashSet<Character>();
for (int i = 0; i < x.length(); i++) {
System.out.println(y.indexOf(x.charAt(i)));
if(y.indexOf(x.charAt(i))!=-1){
set.add(x.charAt(i));
}
}

Iterator<Character> it = set.iterator();
while(it.hasNext()){
System.out.print(it.next());
}

- Praveen Kumar May 17, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

result= []
for x in 'String':
if x in 'Strong':
result.append(x)
print(''.join(result))

- tz May 31, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{
result= []
for x in 'String':
if x in 'Strong':
result.append(x)
print(''.join(result))
}

- tz May 31, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

String A = "string";
		String B = "strong";
		char count[] = new char[50];
		char[] c = A.toCharArray();
		char[] d = B.toCharArray();

		int len = c.length;
		int leng = d.length;
		// System.out.println(len);

		for (int i = 0; i < len; i++) {
			for (int j = 0; j < leng; j++) {
				if (c[i] == d[j])

				{
					count[i] = c[i];

				}
			}
			System.out.print(count[i]);
		}

- prabhum July 24, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public class PrintCommonString {

public static void main(String[] args) {
// set the first Strings

String s1= "strings strings";
String s2= "strongs strongs" ;

// change string to character Array

char[] arrayS1=s1.toCharArray();
char [] arrayS2= s2.toCharArray();

// compare String one by one and print the common on
for (int i=0; i<arrayS1.length;i++) {


if (arrayS1[i]==arrayS2[i]) {
System.out.print(arrayS1[i]);
}
}


}

}

- nags August 17, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

static void Main()
        {
            string s1 = "string";
            string s2 = "strong";
            HashSet<char> chars = new HashSet<char>();
            foreach (char c in s1)
                chars.Add(c);
            foreach(char c in s2)
            {
                if (chars.Contains(c))
                    Console.Write(c);
            }
            Console.ReadLine();
        }

- sss September 13, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1. Both valid strings
2. single characters
3. string1 with lower case, string2 with uppercase with same alphabets
e.g. "string","STRING"
4. Both empty strings
6. Both are nulls
7. Both with blank spaces
8. Both with special chars like \t,\n
9. Performance testing to check the performance of the program by increasing the characters in both the strings
10. Load testing-->check how the program is impacted with increased number of users
11. Stress testing
12. Endurance testing-->continuously sending the strings for long duration
13. Localization testing(if required)-->to check if the program supports localization

- sss September 13, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Here is my take in C#:

string inpStr1 = "String";
            string inpStr2 = "Strong";
            string newStr = "";
            for (int i1 = 0; i1 < inpStr1.Length; i1++)
            {
                for (int i2 = 0; i2 < inpStr2.Length; i2++)
                {
                    if (inpStr1[i1].ToString() == inpStr2[i2].ToString())
                    {
                        newStr += inpStr1[i1].ToString();
                    }
                }
            }

            Console.WriteLine("Output string: " + newStr);

- vg0453 October 22, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def common_char(a,b):
    c = ''
    for i in a:
        if i in b:
            c = c + i
    print c

a = 'string'
b = 'strong'
common_char(a,b)

- Gopinath November 03, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Here is my Python code for it.

def common_char(a,b):
    c = ''
    for i in a:
        if i in b:
            c = c + i
    print c

a = 'string'
b = 'strong'
common_char(a,b)

- Gopinath November 03, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public void removeNonDup(String s1, String s2){
		if(s1==null || s2 == null){
			System.out.println("string cant be null");
		}
		else{
		char[] c1 = s1.toCharArray();
		char[] c2 = s2.toCharArray();
		StringBuffer sb = new StringBuffer();
		HashSet<Character> m = new HashSet<Character>();
		for(char ch : c1){
				m.add(ch);
		}
		for(char ss : c2){
			if(m.contains(ss)){
				sb = sb.append(ss);
			}
		}
	
		System.out.println(sb);
		}
	}

	public static void main(String args[]){
		RemoveNonDupCharBetween2Strings r = new RemoveNonDupCharBetween2Strings();
		r.removeNonDup("string", "strong");
		r.removeNonDup("", "");
		r.removeNonDup("  ", "   ");
		r.removeNonDup(null, null);
		r.removeNonDup(null, "1234");
		r.removeNonDup("12346", "12345");
		r.removeNonDup("sstring", "sstrong");
		r.removeNonDup("sstrign", "sstrgno");
	}

- anonymousNg November 12, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

for(int i=0;i<str.length;i++)
			{
				boolean valExist= false;
				String value= str[i];
				for (int j=0;j<str1.length;j++)
				{
					if(str[i].equals(str1[j]))
					{
						System.out.println(str[i]);
						valExist=true;
						break;
					}
				}

- Unique December 25, 2017 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

python---->

def check(x,y):
temp = ""
for u,v in zip(x,y):
if u == v:
temp = temp+u
print(temp)

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

def check(x,y):
temp = ""
for u,v in zip(x,y):
if u == v:
temp = temp+u
print(temp)

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

1.Check if both null
2.Check if ("","strong")
3.Check if("string","")
4.Check if capital sensitive
5.Check if ("a","a")
6.Check if two long string
7.Check if duplicate character
8.Check if specific characters
9.Check if (" "," ")
10.Check if(null,null)
11.Check if ("",null)
12.Check if both numbers

- zff April 18, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static string returnElement(string a1, string a2)
{
var returnString = new System.Text.StringBuilder();
foreach (char x in a1)
{
foreach(char y in a2)
{
if(x == y ) { returnString.Append(x); }
}
}

return returnString.ToString();
}

- sathishwaran.selvaraj October 12, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Test Cases :
1. Check for happy paths
2. Check for one null and other string
3. Check for one string and other null value
4. Check for both null
5. Check for both empty strings
6. Check for case sensitivity
7. Check for whitespaces
8. Check with different lenghts
9. Check for matching chars at different positions
10. Check for special characters
11. Check for numbers in strings
12. Check for strings with spaces in between for eg. Email me when done and Email you when not done
13. Check for extremely long strings.
14. Check for endurance testing on this

- Brij September 14, 2019 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {
String str1 = "Strong";
String str2 = "String";
if(str1 == null || str1.length() == 0 || str2 == null || str2.length() == 0){
System.out.println("String/s null");
}
String res = "";
for(int i=0 ; i< str1.length() ; i++){
if (str1.charAt(i)==str2.charAt(i)){
res= res + str1.charAt(i);
}
else {
continue;
}
}
System.out.println(res);
}

- Anonymous July 13, 2020 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public static void main(String[] args) {
String str1 = "Strong";
String str2 = "String";
if(str1 == null || str1.length() == 0 || str2 == null || str2.length() == 0){
System.out.println("String/s null");
}
String res = "";
for(int i=0 ; i< str1.length() ; i++){
if (str1.charAt(i)==str2.charAt(i)){
res= res + str1.charAt(i);
}
else {
continue;
}
}
System.out.println(res);
}

- Apeksha July 13, 2020 | 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