# 1K

Sollicitatievragen voor Senior Software Test Engineer gedeeld door sollicitanten

## Meest gestelde sollicitatievragen

Sorteren: Relevantie|Populair|Datum
Er werd een Senior Software Engineer In Test gevraagd...20 september 2015

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

6 antwoorden

#!/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() Minder

//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)); } } Minder

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] Minder

Meer reacties weergeven

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

5 antwoorden

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(.*)")); } } Minder

Use KMP

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

Meer reacties weergeven

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

3 antwoorden

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. Minder

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. Minder

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 Minder

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

3 antwoorden

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

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; } Minder

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; } Minder

### 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.

3 antwoorden

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. Minder

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 Minder

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. Minder

### 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.

3 antwoorden

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() Minder

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; } Minder

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); } } Minder

### Public int compareTo(object o) { Employee emp = (Employee)o; return this.id - e.id; }

3 antwoorden

Output should be 0. Since compareTo() implements Comparable interface.

### Write a program to remove vowels from a given string

2 antwoorden

class Vowels{ public static void main(String args[]){ String input = "abcdefgh"; String vowels = "aeiou"; String output = ""; for(int i=0;i Minder

write a program to define whether an array is sorted or not

### How do you check whether String contains any duplicate characters?

2 antwoorden

I answered him by saying Get a byte array and Get each character of String, Convert it to ASCII number and mark the position of byte array as that of ASCII number Minder

var inputValue = "aabcdefgghi" ; var result = OnlyOnceCheck(inputValue); Console.WriteLine(result.ToString()); public static bool OnlyOnceCheck(string input) { return input.GroupBy(x =&gt; x).Any(g =&gt; g.Count() &gt; 1); } Minder

### what time would be a good time for us to miss your interview time at?

2 antwoorden

the time we scheduled

Recruiter lied to me as well. Never called but told called multiple times. Liers in TA team. Minder

Weergave: 1 - 10 van 1.043 sollicitatievragen