# Test Development Engineer Interview Questions

Test development engineer interview questions shared by candidates

## Top Interview Questions

Implement a Queue using 2 Stacks 3 AnswersUntil the first de-queue operation, keep pushing one of the stacks, say stack1, for every enqueue operation. When you encounter the first dequeue operation, then pop stack1 into stack2. Now, pop stack2, to get the dequeued element. Henceforth, on every dequeue operation, pop stack2, and on every enqueue operation, push stack1. At some point, stack2 might become empty, but this brings you back to the first stage ! Here is an idea: public class StacksQueue { private readonly Stack stack1 = new Stack(); private readonly Stack stack2 = new Stack(); private Stack dequeueStack; private Stack queueStack; private Stack secondaryStack { get { if (object.ReferenceEquals(queueStack, stack1)) { return stack2; } else { return stack1; } } } public StacksQueue() { queueStack = stack1; } public void Queue(T item) { int count = 0; while (queueStack.Count > 0) { secondaryStack.Push(queueStack.Pop()); count++; } queueStack.Push(item); for (int i = 0; i < count; i++) { queueStack.Push(secondaryStack.Pop()); } if (dequeueStack == null) { dequeueStack = queueStack; } queueStack = secondaryStack; } public T Dequeue() { if (dequeueStack == null) { throw new InvalidOperationException("Trying to dequeue from queue which is empty"); } T result = dequeueStack.Pop(); if (object.ReferenceEquals(dequeueStack, stack1)) { dequeueStack = stack2; } else { dequeueStack = stack1; } if (dequeueStack.Count == 0) { dequeueStack = null; } return result; } } Hi, here is a smart solution in java based on shan.phreak solution : class Queue { Stack stack1 = new Stack(); Stack stack2 = new Stack(); public void push(Integer value){ while (!stack2.isEmpty()){ stack1.push(stack2.pop()); } stack1.push(value); } public Integer dequeue(){ while (!stack1.isEmpty()){ stack2.push(stack1.pop()); } return stack2.pop(); } } |

Write a function to find the maximum sum of sub array where the array can have negative and positive numbers. 4 AnswersDon't jump to the answer. As some of you noticed, the question has ambiguties. Ask questions to clarify the question. They would like you to solve the problem after understanding all the details so that you won't miss any edge cases in your solution. Hint: The answer is recursive. answer in java: int array[] ={1,2,3,-6,5,6,9}; table = new int[7][7]; int i, j; int localMax = -999999999; for(i = 6 ; i >= 0 ; i--) for(j = i ; j < 7 ; j++) { if(i == j) table[i][j] = array[i]; else table[i][j] = array[i] + table[i+1][j]; localMax = Math.max(localMax, table[i][j]); } System.out.println(localMax); In Python: def largest_segment(s): y = 0 z = 0 for i in range(0, len(s)): y = max(y + s[i], 0) z = max(z, y) return z Algorithm is O(n). Only works if the max value for an array containing all negatives is 0. Show More Responses def maxSumSubArray(inputArray): currentSum = 0 grandSum = 0 for i in range(len(inputArray)): if (currentSum + inputArray[i]) < currentSum: currentSum = 0 continue else: currentSum = currentSum + inputArray[i] if (grandSum < currentSum): grandSum = currentSum return grandSum |

Given an integer write a function that converts the input into a linkedList where each node corresponds to a number of the integer. Eg: 25697 == 2 -> 5 -> 6 -> 9 -> 7 Then write a function that takes 2 linkedList, add the corresponding integers and return a third list with the result. 3 AnswersThe is a blog discussing how to add two numbers in two lists, with the following link: http://codercareer.blogspot.com/2013/02/no-40-add-on-lists.html Hi Harry, I used your website a lot when I was studying for interviews. Certainly helped me get the internship. Thanks for your time! /* Jun Zheng, Rice Univ C++, Xcode 4.5.2 Interview question of GS Convert a number to linked list. Need reverse. */ node* numToLinkedList(int num){ if(abs(num)* p=new node(); p->next=numToLinkedList(num/10); p->data=num%10; return p; } //Reverse the list void reverse(node* &phead){ if(phead==NULL ||length(phead)==1) return; node* p1=phead->next; node* p2=NULL; phead->next=NULL; while(p1->next != NULL){ p2=p1->next; p1->next=phead; phead=p1; p1=p2; } p1->next=phead; phead=p1; } |

Code a function in C to get the largest consecutive addition of integer numbers fron an array. 3 Answers/* Haven't done C in a while, so pardon me. * Essentially, you have to use dynamic * programming (see Wikipedia entry on the * subject if you are unfamiliar). Create * a table where one dimension represents * where we start summing ints, and the * other dimension represents where we end * summing ints. Because not all table * entries will be valid, we'll only be * filling half of the table. */ #define MAX(a,b) ((a) > (b) ? (a) : (b)) int largest_sum(int array[]) { /* Create our memoization table */ int max_sum = INT_MIN, i, row, col; int array_size = sizeof(array) / sizeof(int); int **mem_table = (int**)malloc(array_size * sizeof(int*)); for (i = 0; i = column are * nonsensical and are ignored. */ for (row = 1; row < array_size; ++row) { for (col = row; col < array_size; ++col) { mem_table[row][col] = mem_table[row][col-1] + array[col]; max_sum = MAX(max_sum, mem_table[row][col]); } } return max_sum; } Blech, that's what I get for posting code without testing it first. Sorry about the double-post; wish I could edit my entry. int largest_sum(int *array, int array_size) { /* Create our memoization table */ int max_sum = INT_MIN, i, row, col; int **mem_table = (int**)malloc(array_size * sizeof(int*)); for (i = 0; i = column are * nonsensical and are ignored. */ for (row = 0; row < array_size - 1; ++row) { for (col = row + 1; col < array_size; ++col) { mem_table[row][col] = mem_table[row][col-1] + array[col]; max_sum = MAX(max_sum, mem_table[row][col]); } } return max_sum; } best = 0; current = 0; for (int i=1 to n) { current = MAX(current + array[i], array[i]) best = MAX(current, best) } return best; Complexity O(n), additional memory used O(1) Proof: MaxSuffixSum(empty) =0 MaxSuffixSum(a[1..n]) = MAX(MaxSuffixSum(a[1..n-1]) + a[n], a[n]) where MaxSuffixSum is a largest sum of numbers from some i to n. The largest consecutive sum is some suffix, so it is enought to calculate best suffixes ending at all indexes in the array and pick the best one. |

Check if tic-tac-toe has a winner 4 AnswersTic-Tac-Toe is game like soduku or checkers that is represented as having columns and rows which translates as a 2 Dimensional array. In this case a 3x3 array. Represented as [0][0] [1][0] [2][0] You would therefore permutate each possibility. .... ..... ...... ...... ..... ..... [2][2] It's all about state. You can only win on the placement of a token so check the possible ways to win from this position. So say the user places a value in the bottom left corner. Then you need only check the vertical, horizontal and the diagonal from this position. From the center position you will need to check 4 different positions (+ and x). This retains a O(1) solution but then again this only works if you can keep count of how many moves have already occurred. @Matt: I like your approach, but still question in doubtful. We have final state of game or we have to write decision function after every move? Show More Responses @VIctor.. It does not matter that we have final state or not we need to check with every input from users..and probably the check function gonna check on 8 places ... |

You are in a room by yourself and someone walks into the room, asks you to find the temperature, and leaves. How would you find the temperature in the room without leaving the room? 3 AnswersCall a friend to bring a thermometer over. Cut a 5cm*5cm*5cm ice cube from the refrigerator, and test how long it take for it to melt completely. Find two equal size ice cubes, for the first one, wait till it melts completely(0 ℃) , heat it till it boils, record the time t1. For the second one, wait long enough till the water has the same temperature with the room, than heat it till it boils, record the time t2. The room temperature is 100*t2/t1. |

reverse a linked-list 3 Answerssimple declare 2 temperary variables and store the links of the variables of link list sequencially and alter the links make 1st link null. you'll need 3 pointers here You will need 3 pointers and iterate through the list, then reverse each element |

Write a program takes in a string and a delimiter, and uses that delimiter to split a string and then will reverse the characters in every word (or jumble of characters between the delimiters), stuffing them back into a string when finished. ('The dog walks' becomes..... 'ehT god sklaw') 4 Answersin C# static string ReverseStrings(string original, char splitter) { if (string.IsNullOrEmpty(original)) return null; int currentSplitIndex = -1; int p1 = 0, p2 = 0; while (p2 < original.Length) { while (p2 < original.Length && original[p2] != splitter) p2++; if (p2 < original.Length) //p2 points to separator { Reverse(ref original, p1, p2 - 1); p1 = ++p2; } } return original; } static void Reverse(ref string org, int start, int end) { for (int i = start; i <= start + (end - start) / 2; i++) { var c1 = org[i]; var c2 = org[end - i + start]; org = org.Remove(i, 1); org = org.Insert(i, c2.ToString()); org = org.Remove(end - i + start, 1); org = org.Insert(end - i + start, c1.ToString()); } } public void ReverseEachWordOfString(string orignal, char del) { int errorCode = 0; List list = SplitString(orignal, del, out errorCode); if (errorCode == -1) { Console.WriteLine("Empty string provide, Please provide valid input"); } else if (errorCode == -2) { Console.WriteLine("Empty delimiter provide, Please provide valid input"); } else { StringBuilder strbld = new StringBuilder(); char[] revString; foreach (var item in list) { revString = new Char[item.Length]; for (int i = 0, j = item.Length - 1; i SplitString(string orignal, Char del, out int errorCode) { errorCode = 0; List list = new List(); if (orignal == null || orignal == string.Empty) { errorCode = -1; return null; } if (del == null) { errorCode = -2; return null; } StringBuilder str = new StringBuilder(); for (int i = 0; i < orignal.Length; i++) { if (orignal[i] == del) { list.Add(str.ToString()); str.Clear(); } else { str.Append(orignal[i]); } } return list; } using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Reverse_Words { class Program { static void Main(string[] args) { string revString = string.Empty; string bufferString = string.Empty; string inputString = ""; // Checking input if (string.IsNullOrEmpty(inputString)) { Console.WriteLine("Input is empty"); inputString = Console.ReadLine(); } // Asuming word is set of leters and not include any other chars like "-" or "'" for( int i = 0; i = 65) & (Convert.ToByte(inputString[i]) = 0; i--) { outString += wordString[i]; } return outString; } } } Show More Responses def splitReverseString(inputArray,delimeter): tempArray = [] tempElement = '' if len(inputArray) == 0: return 'Null String' for i in range(len(inputArray)): if (inputArray[i] != delimeter): tempElement = tempElement + inputArray[i] else: tempArray.append(tempElement) tempElement = '' tempArray.append(tempElement) for j in range(len(tempArray)): tempElement = '' temp = tempArray[j] for k in range(len(temp)-1,-1,-1): tempElement = tempElement + temp[k] tempArray[j] = tempElement return tempArray |

You have a building with 100 stories. You also have two glass balls. You can drop the glass balls as many times as you want before they break. How can you find the floor at which they start breaking with the fewest number of drops? 3 AnswersNot truly a brain teaser because the answer is mathematical. If you have N stories, you use the first glass ball to increment by sqrt(N) stories. Once that ball breaks, you use your second to go to the level of sqrt(N) below where it broke, and increment floor by floor. You know it must break somewhere in that group of sqrt(N) stories. I believe this method gets you a runtime of O(n^0.5). search for "two egg problem". its a minimization of maximum regret problem http://www.datagenetics.com/blog/july22012/index.html |

Write a function to turn a string into an integer and test it 3 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; } |

**21**–

**30**of

**783**Interview Questions

## See Interview Questions for Similar Jobs

- Software Engineer
- Software Development Engineer
- Senior Software Engineer
- Software Developer
- Software Development Engineer I
- Software Engineer In Test
- QA Engineer
- Intern
- Software Development Engineer In Test (SDET)
- Quality Assurance Engineer
- Software Test Engineer
- Test Engineer
- Software QA Engineer
- Software Engineer Intern
- Software Development Engineer II
- Senior Software Development Engineer
- Software Engineering
- Java Developer
- Business Analyst