Questions d'entretiens - Software development engineer in test sdet

2 k

Questions d'entretien pour Software Development Engineer In Test Sdet partagées par les candidats

Principales questions d'entretien

Trier: Pertinence|Populaires|Date
Microsoft
On a demandé à un Software Development Engineer In Test (SDET)...4 septembre 2009

how would you move mount fuji?

27 réponses

I would first answer with, "First, I would analyze the problem and determine if it didn't make better sense to come to the mountain rather than move the mountain. Assuming that's not feasible..." I think that's a key element they're looking for in an answer. That you can look at a major task and first identify if there isn't a better approach. The next element is to determine how you would go about completing a seemingly impossible or gargantuan task. The specifics of this part of the answer don't matter other than to show that you have an understanding that huge problems need to be broken down into smaller, more manageable tasks using the resources you have. Moins

When they ask a quesion like this at MS, they do want an answer. If you tell them that you want to consider alternatives up front, they will wave that off and tell you that, in this hypothetical situation, alternatives were already considered and that moving the mountain is the approach was chosen. They really want you to answer the question. The point of this question is - process. They want to see what process you use to solve problems. It is important to show that you solve the problem not by arranging and re-arranging a series of random thoughts but that you can approach it methodically and that this methodology can be applied to any problem. Do not to to some up with a clever answer that attempts to solve the problem - they will just keep insisting that you tackle the problem. If you don't, you won't pass the interview. So, brush up on your problem solving process before you interview at MS. Use these questions as an opportunity to impress them with how well you can solve difficult problems. Moins

This is a common dorky Computer Science joke. The answer I believe they are looking for is that you use the Tower of Hanoi algorithm to move the mountain (i.e. that the problem of moving Mt. Fuji is reducible to the already-solved Tower of Hanoi problem). This could be accomplished by having a large laser and a couple of really good cranes. Moins

Afficher Plus de réponses
Microsoft

Given a set of numbers -50 to 50, find all pairs that add up to a certain sum that is passed in. What's the O notation for what you just wrote? Can you make it faster? Can you find an O(n) solution? Implement the O(n) solution

16 réponses

Put all the numbers from the array into a hash. So, keys will be the number and values of the keys be (sum-key). This will take one pass. O(n). Now, foreach key 'k', with value 'v': if k == v: there is a match and that is your pair. this will take another O(n) pass totale O(2n) ~ O(n) Moins

Easiest way to do it. Written in python. If you consider the easiest case, when our summed value (k) is 0, the pairs will look like -50 + 50 -49 + 49 -48 + 48 etc.... etc... So what I do is generalize the situation to be able to shift this k value around. I also allow us to change our minimums and maximums. This solution assumes pairs are commutative, i.e. (2, 3) is the same as (3, 2). Once you have the boundaries that you need to work with, you just march in towards k / 2. This solution runs in O(n) time. def pairs(k, minimum, maximum): if k >= 0: x = maximum y = k - maximum else: x = k + maximum y = minimum while x >= k / 2 and y <= k / 2: print str(x) + " , " + str(y) + " = " + str(x + y) x = x - 1 y = y + 1 Moins

here is my solution using hash table that runs in O(2n) => O(n): public static String findNums(int[] array, int sum){ String nums = "test"; Hashtable lookup = new Hashtable(); for(int i = 0; i < array.length; i++){ try{ lookup.put(array[i], i); } catch (NullPointerException e) { System.out.println("Unable to input data in Hashtable: " + e.getMessage()); } } int num2; int num1; for (int i = 0; i < array.length; i++){ num2 = sum - array[i]; Integer index = (Integer)lookup.get(num2); if ((lookup.containsKey(num2)) && (index != i)){ num1 = array[i]; nums = array[i] + ", and " + num2; return nums; } } //System.out.println(lookup.get(-51)); return "No numbers exist"; } Moins

Afficher Plus de réponses
Webtrends

I was asked a pretty straight forward brain teaser during my last phone interview, which they said they don't normally do, but because I put that I was a logical problem solver on my resume they couldn't resist the opportunity to. It was the following "There are 20 different socks of two types in a drawer in a completely dark room. What is the minimum number of socks you should grab to ensure you have a matching pair?"

13 réponses

All of the previous answers are somehow wrong or misleading. "Not-a-mathematician": the method you describe would ensure that you get 2 DIFFERENT socks instead of matching - and only in the situation that the ratio is exactly 50-50. "Anonymous on Oct 20 2012": No, you could also have 3 of the same sock after grabbing 3. "Anonymous on Oct 3": The probability has little to do here, while it is over 0%. THE REAL ANSWER: Given that there are 2 types, and you want to get a MATCHING PAIR (not 2 different socks) you must grab 3. When you have 3, you WILL have at least 2 of the same kind, since there are only 2 kinds available. Moins

1 black : 19 white. .. 3 socks 2 black : 18 white ... 3 socks 3 black : 18 white ... 3 socks 4 black : 16 white.. . 3 socks 5 black : 15 white .. . 3 socks 6 black : 14 white ... 3 socks . .. . .3 socks. why? The worst case scenario is always 2 of one color and one of the other. Moins

Actually, the worst case scenario is you could pick 19 socks and still have ALL the same color if only one is a different color. My solution is "Turn on the light". Moins

Afficher Plus de réponses
Expedia Group

Describe and code an algorithm that returns the first duplicate character in a string?

11 réponses

first clarify if it is ASCII or UNICODE string For ASCII, create BOOL checkArray [128] = {false}; walk the string and update the index of checkArray based of the character. for (int index=0;index< strlen(str); index++) { if (checkArray[str[index]] == true) { printf (str[index]); return; } else { checkArray[str[index]] = true; } } Moins

for (int i=0;i

public static in findDuplicateChar(String s) { if (s == null) return -1; char[] characters = s.toCharArray(); Map charsMap = HashMap(); for ( int index = 0; index < characters.length; index++ ) { // insert the character into the map. // returns null for a new entry // returns the index if it previously if it existed Integer initialOccurence = charsMap.put(characters[index], index); if ( initialOccurence != null) { return initialOccurance; } //there where no characters that where duplicates return -1; } } Moins

Afficher Plus de réponses
Microsoft

Data structures and Algorithms related

2 réponses

plz tell me which type of question put up in interview

Iam ready

Microsoft

Consider a stack of N number of cards which are piled up and in facing down. Each card has a unique number from the range 1 to N. The card is stacked in such a way that it exhibits the following behavior: Take the first card and put it under the stack without revealing. Now the next card on the top will have the number 1 on it. Next take 2 cards one after the other and put is under the stack without revealing. Yes you guessed it right - the next card on the top will reveal a value of 2. This goes on. Eg. for such a series : 9,1,8,5,2,4,7,6,3,10 [for N=10] Write a program to generate such a series for a given N number of cards so that this behavior can be exercised.

8 réponses

// Short and simple C++ algorithm #define N 10 void compute(int stack[]) // Make sure N elements are allocated { int j=0; for(int i=0; i Moins

The algorithm used is: For each number n (ranging from 1 to 10), we have to skip n places in the array. And then put number n at that position. The catch in the program is that we can skip only, not occupied places (the array places where value is 0 by default). Also, when we reach the end of the array, we have to move back to beginning of array (similar to cards being kept at the bottom of the pile of cards.) Here, a variable 'pos' is used to store the final position of any element. Initially, pos is at 0. The skip() takes the array, the current value of pos and the number of skips to be made. For example, for n=1, the values passed to skip() would be: pos=0, n=1. This means that we have to skip 1 place starting from index 0. Similarly, for n=2, pos=1. This means we have to skip 2 places starting from index 1. Java Implementation: public class StackOfCards { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int[] arr = new int[10]; int pos=0; for(int n=1;n0){ if(arr[pos]==0){ //reduce the number of skips to be made n--; } pos++; //if end of array is reached, take pos back to beginning if(pos==10){ pos=0; } } // keep incrementing pos until a not occupied index is reached. while(arr[pos]!=0){ pos++; } return pos; } } Moins

Here is C# Code... namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n = 36; int[] series = new int[n]; int LargestNumber = n; int SmallestNumber = 1, temp = 1, i; bool putLargeNumber = true; for (i= 0; i 0)) { series[i] = LargestNumber; Console.Write("{0} ", series[i]); LargestNumber = LargestNumber - 1; putLargeNumber = false; temp--; } else { series[i] = SmallestNumber; Console.Write("{0} ", series[i]); SmallestNumber += 1; putLargeNumber = true; temp = SmallestNumber; } } } } } Moins

Afficher Plus de réponses
Microsoft

In a given sorted array of integers remove all the duplicates.

8 réponses

The array is already sorted, no need for a set. example: 2,2,5,7,7,8,9 Just keep tracking the current and previous and the index of the last none repeated element when found a difference copy the element to the last none repeated index + one and update current and previous, no extra space and it will run in O(n) Moins

public RemoveDuplicates() { int[] ip = { 1, 2, 2, 4, 5, 5, 8, 9, 10, 11, 11, 12 }; int[] op = new int[ip.Length - 1]; int j = 0, i = 0; ; for (i = 1; i <= ip.Length - 1; i++) { if (ip[i - 1] != ip[i]) { op[j] = ip[i - 1]; j++; } } if (ip[ip.Length - 1] != ip[ip.Length - 2]) op[j] = ip[ip.Length - 1]; int xxx = 0; } Moins

public static void removedup(int[] input){ int count =1; int i=0; for( ;i Moins

Afficher Plus de réponses
Microsoft

* Merge two sorted linked list. The merged list should also be sorted. * Compact a string. i.e remove spaces * traverse a link list containing char* as data. test cases for the same. * reverse a string. test cases for the same. * remove all the given characters from a string.

6 réponses

* Compact a string. i.e remove spaces * public class CompactString { String compactString(String s) { String a = ""; String[] tabStrings = s.split(" "); for (String t : tabStrings) a += t; return a; } } Moins

* reverse a string. public class ReverseString { String reverseString(String str) { String rev = ""; for (int i = str.length() -1 ; i >= 0; i--) rev += str.charAt(i); return rev; } } Moins

remove all the given characters from a string. public class RemoveChar { String removeChar(String s, char c){ String a = ""; for(int i = 0; i < s.length(); i ++){ if(s.charAt(i) != 'a') a += s.charAt(i); } return a; } } Moins

Afficher Plus de réponses
Microsoft

given two linked lists with a digit in each node, add the two linked lists together. the result must be a linked list with one digit in each node. use only one iteration of the two input lists.

6 réponses

I think the answer should traverse both link lists and add each node data and make a new link list with digit on each node of the answer. In this way we can traverse in N time and at the end if any nodes are left in second link list we can attach them at the end of new link list Moins

//I hope this Solution Would help public ListNode reverse(ListNode head) { ListNode current=head; ListNode previous=null; ListNode next=null; while(current!=null) { next=current.next; current.next=previous; previous=current; current=next; } return previous; } public ListNode addTwoNumbers(ListNode head1,ListNode head2) { head1=reverse(head1); head2=reverse(head2); int sum=0;int carry=0; LinkedList result = new LinkedList(); while(head1!=null || head2!=null ) { sum=((head1==null) ?0 :head1.value )+ ((head2==null) ?0 :head2.value)+carry; //carry=0; if(sum>9) { carry=sum/10; sum=sum%10; } else { carry=0; } result.add(sum); if(head1!=null) { head1=head1.next; } if(head2!=null) { head2=head2.next; } } if(carry!=0) { result.add(carry); } ListNode dummy=reverse(result.head); return dummy; } Moins

Is this to remove duplicates from linked list or just combining both the linked lists blindly? Moins

Afficher Plus de réponses
Microsoft

Are two words palindrome of each other?

6 réponses

I solved by Sorting as well as using HashMap. I was asked to implement sort which I had never encountered in my past interviews. Moins

My version public class PalindromTwoWords { boolean isPalindrome(String a, String b) { boolean isPalindrome = false; for (int i = 0; i 0; j--) { if (a.substring(0, i).equals(b.substring(j))) isPalindrome = true; } } return isPalindrome; } } Moins

Sorry when i pasted the code some words escaped. public class PalindromTwoWords { boolean isPalindrome(String a, String b) { boolean isPalindrome = false; for (int i = 0; i 0; j--) { if (a.substring(0, i).equals(b.substring(j))) isPalindrome = true; } } return isPalindrome; } } Moins

Afficher Plus de réponses
1 - 10 sur 1 847 Questions d'entretien

Consultez les questions posées en entretiens pour des emplois similaires