Software Test Engineer Interview Questions | Glassdoor

# Software Test Engineer Interview Questions

1,657

Software test engineer interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

Sep 26, 2012

### Software Design Engineer In Test at Amazon was asked...

Jul 28, 2012
 find if 2 strings are anagrams5 AnswershashHash what, lol ? :))) You simply need to alphabetically sort characters in strings and then compare the result.think about the time complexity. Whats the time complexity of the sorting? NlogN And when using hash mapping, it can be only N. Mapping the string to an alphabet array, the index is the char and the value stores the frequency of the char. Hope it helps.Show More Responseseasiest way probably to reduce the characters to ascii, add them all together. If values are equal, they all contain the same characters. O(n)Just reverse one string and then compare the result with other string.

### Software Engineer In Test at Google was asked...

Jun 4, 2013
 Given a 2D rectangular matrix of boolean values, write a function which returns whether or not the matrix is the same when rotated 180 degrees. Additionally verify that every boolean true is accessible from every other boolean true if a traversal can be made to an adjacent cell in the matrix, excluding diagonal cells. That is , (x , y ) can access the set [ ( x + 1 , y ) , ( x - 1 , y ) , (x , y - 1 ) , (x , y + 1 ) ] For example, the matrix { { true , false } , { false , true } } should not pass this test.4 Answersif the matrix A is a11, a12 a21, a22 after 180 rotation a22, a21 a12, a11 so a11 == a22 and a12 == a21 function is BOOL isSame = (a11==a22) && (a12==a21) done.public static boolean isMatrixEqualToFlip(boolean[][] matrix) { if (matrix==null || matrix.length == 0 || matrix[0].length == 0) { return true; } int rowlen = matrix[0].length; int highInd = matrix.length/2; int lowInd = highInd - 1 + (matrix.length % 2); System.out.println("rowlen: " + rowlen + " high: "+ highInd + " low: " + lowInd); while (lowInd >= 0) { System.out.println("high: " + highInd + " lowInd: " + lowInd); for(int i=0; i < rowlen; i++) { System.out.println("Compare " + matrix[highInd][i] + " to " + matrix[lowInd][rowlen - 1 - i]); if (matrix[highInd][i] != matrix[lowInd][rowlen - 1-i]) { return false; } } lowInd--; highInd++; } return true; }def rotate180(mtx): col=mtx col.reverse() for row in col: row.reverse() print colShow More ResponsesIf the matrix is: true, false false, true 90 degree rotation would be: false, true true, false 180 degree rotation would be: true, false false, true If we define the matrix as: a11, a12 a21, a22 Then the solution would be: boolean isMatch = !(a11 && a12) && !(a11 && a21) && !(a12 && a22) && !(a21 && a22);

### Software Development Engineer In Test (SDET) at Microsoft was asked...

Jun 18, 2011
 In a BST write a program to find 2 nodes x and y such that X+y=k4 AnswersI think we need to do traversals and check for every node.For a given x traverse nodes upto x + y <= k.This problem requires the use of a map aka dictionary aka hashtable. Visit a node If the node data isn't in the map; add the data to the map. Solve for what the other number should be; check if it's in the map. if it is you're done... otherwise keep searching.Show More ResponsesYou can solve the problem in O(n) time. First you find the smallest number in the tree then you find the highest number (worst-case linear time, logarithmic time if the BST is balanced). If their sum is larger than K, you find the largest number in the tree that is lower than y (you can do it in amortized constant time) If their sum is lower than K, you find the smallest number in the tree that is higher than x (amortized constant time). And you continue this algorithm until you reach the correct X and Y :)

Feb 19, 2013

Nov 11, 2013

Sep 3, 2010

### Software Development Engineer In Test (SDET) at Microsoft was asked...

Oct 7, 2010
 Write a function to turn a string into an integer and test it3 AnswersCString csNum; int nNum = 2; csNum.format("%d", nNum);oops wrong one CString csNum = "1"; int nNum = atoi(csNum);public int AtoI(string str) { bool isNeg = false; int index = 0; if (str[0] == '-') { isNeg = true; index++; } int result = 0; // "123" 123 // 1 * 10 + 2 12 * 10 + 3 int multiple = 1; int number = 0; for (int i = index; i < str.Length; i++) { number = str[i] - '0'; result = result * multiple + number; multiple = 10; } if (isNeg) { result = result * -1; } return result; }

### Software Engineer In Test at Google was asked...

Mar 18, 2009
 Design a function which returns the number of set bits in a given number, when expressed in binary4 Answersint numBits(int num) { int numBits = 0; while(num > 0) { if(num % 2) numBits++; num /= 2; } return numBits; }The question stipulates "a number", but the code assumes "a positive integer". (It also assumes the number expressed in binary has a C compiler's default number of bits for type int (e.g. 32); that's probably acceptable since a real-world case would likely specify that type. ) Consider: /* return n of set bits in a signed int */ int numBits(int num) { int numBits = 0; while (num != 0) { if (num < 0) ++numBits; num <<= 1; } return numBits ; }You may get faster results with some precomputing... /* lookup table with number of bits set per byte */ const short lookupTable[256] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, ... }; int numBits(int num) { unsigned char *p = (unsigned char *)# // not necessarily required, but makes for easier reading return lookupTable[p[0]] + lookupTable[p[1]] + lookupTable[p[2]] + lookupTable[p[3]]; // assumes 32 bit integer }Show More ResponsesUse a logarithm, base-2. def num_bits(n): return int(math.log(n, 2) + 1)

Oct 3, 2012