# 2K

Senior Test Engineer interview questions shared by candidates

## Top Interview Questions

Sort: Relevance|Popular|Date
Senior Test Automation Engineer was asked...24 March 2020

### Code to find character count in a given string.

In these sorts of interviews you really need to drill down and understand what the interviewer is looking for. A good way to simulate a real interview experience is to do a mock with one of the EPAM Systems Senior Test Automation Engineer experts on Prepfully, rated super strongly on TrustPilot... prepfully.com/practice-interviews Less

### Search a sorted array for the first element larger than k

#!/usr/bin/env python """Search a sorted array for the first element larger than k. """ def srch(list1, srchItem): """Perform Binary search and find the first element that is larger than the arg srchItem @list1: The sorted list @srchItem: The element to be searched for finding next greater value than that """ len1 = len(list1) startIdx = 0 stopIdx = len1 - 1 stop = False # saveIdx the index of the lowest value in the sorted list saveIdx = -1 while not stop and startIdx &gt;= 0 and stopIdx srchItem: # found greater item, but the previous one also could be greater stopIdx = midIdx - 1 saveIdx = midIdx elif list1[midIdx] srchItem: saveIdx = startIdx break elif startIdx &gt;= len1 or stopIdx &lt; 0: break if saveIdx == -1: return -1 # not found return list1[saveIdx] def testAll(): testList = [3, 6, 9, 34, 67] print 'Test: %s SrchItem: %d' %(testList, 34) print 'Result: %d' %srch(testList, 34) testList = [3, 6, 9, 34, 67, 69] print 'Test: %s SrchItem: %d' %(testList, 34) print 'Result: %d' %srch(testList, 34) # test for result to be the 1ast item in the list testList = [3, 6, 9, 34, 67, 69] print 'Test: %s SrchItem: %d' %(testList, 68) print 'Result: %d' %srch(testList, 68) # test for result to be the ist item in the list testList = [3, 6, 9, 34, 67, 69] print 'Test: %s SrchItem: %d' %(testList, 1) print 'Result: %d' %srch(testList, 1) # item not in the iist testList = [3, 6, 9, 34, 67, 69] print 'Test: %s SrchItem: %d' %(testList, 70) print 'Result: %d' %srch(testList, 70) if __name__ == '__main__': testAll() Less

//Run time complexity is logn public class FirstGreatestNumberThanK { public int prepareFirstGrtst(int[] a, int k) { return firstGrtst(a, 0, a.length - 1, k); } public int firstGrtst(int[] a, int start, int end, int k) { if (end == start + 1) { if (a[start] &gt; k) return a[start]; else return a[end]; } else { int mid = (start + end) / 2; if (k == a[mid]) return a[mid + 1]; if (k &gt; a[mid]) { start = mid; return firstGrtst(a, start, end, k); } else { end = mid; return firstGrtst(a, start, end, k); } } } public static void main( String[] args){ FirstGreatestNumberThanK f = new FirstGreatestNumberThanK(); // int[] a = {2,4,6,8,9,12,14,16}; // even length int[] a = {2,4,6,8,9,12,14}; // odd length // System.out.println(f.prepareFirstGrtst(a, 11)); // System.out.println(f.prepareFirstGrtst(a, 3)); // System.out.println(f.prepareFirstGrtst(a, 7)); // System.out.println(f.prepareFirstGrtst(a, 15)); // execute for even length data // System.out.println(f.prepareFirstGrtst(a, 14)); // execute for even length data // System.out.println(f.prepareFirstGrtst(a, 4)); System.out.println(f.prepareFirstGrtst(a, 12)); System.out.println(f.prepareFirstGrtst(a, 2)); } } Less

def find_greater(aList, item): high = len(aList) low = 0 while low &lt; high: mid = (high + low) // 2 if item &lt; aList[mid]: high = mid else: low = mid + 1 return aList[low] Less

### There is a body of water that starts with 1 square unit, and doubles in size every day (2 units after 2 days, 4 units after 4 days). It takes 100 days to fill up. How many days would it take to fill if you started with 2 square units?

100 - 1 = 99 days

Starting with 2 square units at time t=0 is like 1 square unit at t = 1. [this logic is the key to answering the question]. Now let's do the first few cases. t = 0: size = 1+1 = 2 t = 1: size = 2(1+1) = 2+2 = 4 = f(2) in the 1 unit case. Pretty easy to see it only requires 1 time period less from here. The OP was right. Less

This question is phrased incorrectly. I think you meant "4 units after 3 days". Which makes your answer wrong as well. This is not helpful at all. Less

### Given a string, konylabsinterview write a program to return bool if a given pattern matches.pattern example - kon*lab*terview*

public class Test{ public static void main(String args[]){ String Str = new String("konylabsinterview"); System.out.print("Return Value :" ); System.out.println(Str.matches("kon(.*)lab(.*)terview(.*)")); } } Less

Use KMP

Hi, Please see if you can provide the details of the question posed in the context of binary search tree. Thanks. Less

### How would you translate input string into sequence of movements through on screen keyboard? What if you can loop through rows and columns?

Keep in mind that using matrix will leave you with quadratic running time. Using looping rows and columns will make algorithm slightly more complex, just have to decide which direction is it faster to move. Quite interesting optimal path question overall. Less

So if I'm understanding correctly, you're given a string (e.g. "Star Wars") and an on-screen keyboard accessible through an up-down-left-right controller. The goal is to be able to convert a given string into a sequence of UDLR commands that will enter that string through the keyboard. What if you pre-calculated a map of the optimal path between any two keys? Store it in a hashmap where the key is "current_position+desired_position" (e.g. from "Star Wars", you would have entries for "S+t", "t+a", "a+r", etc.) and the value is a sequence of U+D+L+R indicating the cursor moves. You could even get clever and store it as some kind of routing table, similar to what is used for internet routers. Think of each letter on the keyboard as a router that has a route to each of its neighbors in the UDLR directions. Then, inject a dictionary of strings into the network based on movie titles, actor names, etc. from each "endpoint" and let it learn the most efficient way to enter each of them. This way, when you go to internationalize or change keyboard layouts, you can re-create an efficient map automatically. Less

It's essential to demonstrate that you can really go deep... there are plenty of followup questions and (sometimes tangential) angles to explore. There's a lot of Senior Software Engineer In Test experts who've worked at Netflix, who provide this sort of practice through mock interviews. There's a whole list of them curated on Prepfully. prepfully.com/practice-interviews Less

### Find indices start and end for a particular value in a sorted integer array with duplicates

Explained simple way to do this using linear search and binary search and coded up using binary search Less

public int firstOccur(int[] arr, int k) { if (arr == null || arr.length combinedOccur(int[] arr, int k) { BinarySearchOccurences obj = new BinarySearchOccurences(); int startIndex = obj.firstOccur(arr, k); int endIndex = obj.lastOccur(arr, k); if (startIndex == -1 || endIndex == -1) { throw new IllegalArgumentException("k does not exist in array"); } ArrayList result = new ArrayList(); result.add(startIndex); result.add(endIndex); return result; } Less

public int firstOccur(int[] arr, int k) { if (arr == null || arr.length combinedOccur(int[] arr, int k) { BinarySearchOccurences obj = new BinarySearchOccurences(); int startIndex = obj.firstOccur(arr, k); int endIndex = obj.lastOccur(arr, k); if (startIndex == -1 || endIndex == -1) { throw new IllegalArgumentException("k does not exist in array"); } ArrayList result = new ArrayList(); result.add(startIndex); result.add(endIndex); return result; } Less

### Coding: Create a stack with the usual push() &amp; pop(), but with an additional function getMiddle() that returns the middle element of the stack in constant time.

import os import re import sys class Stack: def __init__(self): self.arrList = [] def isEmpty(self): if len(self.arrList): return False else: return True def push(self, val): self.arrList.append(val) def pop(self): if not self.isEmpty(): self.arrList[len(self.arrList)-1] self.arrList = self.arrList[:len(self.arrList)-1] else: print "Array list is empty" def returnMiddle(self): if not self.isEmpty(): mid = len(self.arrList)/2 return self.arrList[mid] else: print "Array list is empty" def listStack(self): print self.arrList s = Stack() s.push(5) s.push(6) s.listStack() print s.returnMiddle() s.pop() s.listStack() s.push(20) s.push(45) s.push(435) s.push(35) s.listStack() print s.returnMiddle() s.pop() s.listStack() Less

public int getNext(int[] ar, int k) { int low = 0; int high = ar.length-1; int mid = low+(high-low)/2; if (ar[high] k &amp;&amp; (mid==0 || ar[mid-1]&lt;=k)) { return ar[mid]; } if(ar[mid]&lt;=k) { low = mid+1; } else { high = mid; } mid = low+(high-low)/2; } return -1; } Less

public class CreateStack { List l = new LinkedList(); public void push(Integer i) { l.add(i); } public void pop(){ l.remove(l.size()-1); } public Integer getMiddle(){ return l.get((l.size()-1)/2); } } Less

### Couple of questions asked at the interview I could not get my head around and never expected in an interview in a company like Pearson which is internationally recognized. 1.You are just 2 years in United States and looking for a job change? 2.Why are you looking for a full time opportunity?(Seems the person did not read my resume carefully that I am full-time employee with Cognizant for more than 8 years now) These questions asked does not support the claim of Pearson that it is a equal opportunity employer.And proves there are discriminations made.

I think those 2 are valid questions. When they asked about moving out in 2 yrs, they might be trying to get handle on you whether you have any cultural issues working in United States. When they asked about full time. They did fully understood your resume and asked that question. You are full time to cognizant, and might be working at some client location as contractor to client from cognizant and not working at Cognizant location and on a Cognizant product. The interviewer fully understood how cognizant, TCS and Wipro full time employees work in United states. Moreover, I dont think these 2 questions and answers to questions make them to take different decision. I disagree with your comment on equal opportunity employer and discrimination comment. I know lot of people from different background and different countries working at Pearson. I hope you will find a good opportunity in future. All the best. Less

To add more to what i have said above. The banking company and the broadcasting i mentioned in my earlier post both have employees coming from different background and countries but my experience was completely different. It is the people who represent an organisation and i still believe this kind of questions represents Pearson that it is not 'fully' equal opportunity employer and discrimination are made. Thanks Less

To begin with this was not my first onsite interview in the united states. Early last year i got a full time offer of senior developer with the largest broadcasting and cable television company in the world.Due to personal reason i did not join that company.And i have an open invitation from the Director of Engineer (the hiring manager)of that company to consider working with that company in future.There were four rounds of technical interview and then interview with the hiring manager,none of them asked how long have i been in the united states instead the hiring manager took me to lunch with him (the very first day i met with this person). The second onsite interview was with the eighth-largest bank holding company in the United States. And this time to my utter surprise one of the hiring managers told me "Now a days Indian IT companies like Tata Consultancy Services no longer bringing their employees on H-1B instead they are bringing employees on L1 Visa so that employees can not change their jobs in USA".I do not think any sane interviewer can tell all this in an interview.Well this time i did not get an offer and i was happy that i did not. Now coming to interview at Pearson, the question "You are just 2 years in United States and looking for a job change?" is not at all valid to the best of my knowledge. If the interviewer had intention of knowing whether i have any cultural issues he could have asked the question in thousand different ways but not the way i was asked And you know it better. This short of questions comes out of prejudice not ignorant. I can challenge if there were a single wrong answer given during technical phone screen and in the onsite technical round.So where is the feedback of my technical interview. Just saying " we have decided to concentrate our attention on other candidates who we believe best meet the current needs of our organization" does not put proper light into the evaluation process. My advice is try to hire 'Characters' not skills because skills are cheap these days. Best of luck with finding talent!!! Thank You. Less

### A quick programming question. Count from 1 to 100 and write 'X' if the current number can be divided by 3 or 'Y' if by 5 and 'Z' if both.

public class Func35 { public static void main(String[] args) { for(int i=1;i&lt;=100;i++){ if(i%3==0 &amp;&amp; i%5==0){ System.out.print("Z"+","); } else if(i%3==0){ System.out.print("X"+","); } else if(i%5==0){ System.out.print("Y"+","); } else { System.out.print(i+","); } } } } Less

for(int i=1;i&lt;=100;i++) { boolean flag=false; if(i%15==0) { System.out.println(i+"Z"); flag=true; } else if(i%3==0 &amp;&amp; flag==false) { System.out.println(i+"X"); flag=true; } else if(i%5==0&amp;&amp;flag==false) { System.out.println(i+" Y"); } } Less

Used a bool variable added the two division in the loop (with the loop variables) (i%5 and i%3). The first division only sets the bool variable and the second division writes the output according Less