Microsoft interview question

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

Interview Answers

Anonymous

12 Sept 2017

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

Anonymous

12 Sept 2017

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

Anonymous

12 Sept 2017

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

Anonymous

22 May 2020

//Merging two Sorted LinkedList class ListNode{ ListNode next; int data; public ListNode(int data) { this.data=data; this.next=null; } public ListNode mergeSortedLists(ListNode head1,ListNode head2) { ListNode dummy =new ListNode(-1); ListNode head=dummy; while(head1!=null && head2!=null) { if(head1.data

Anonymous

22 May 2020

public ListNode mergeSortedList(ListNode head1,ListNode head2) { ListNode dummy = new ListNode(-1); ListNode head=dummy; while(head1!=null && head2!=null) { if(head1.value

Anonymous

26 Feb 2021

Through questions like this, interviewers are mostly trying to test your skillset (and its relevance to the role) as robustly as possible, so be prepared for multiple offshoots and followups. It could be a useful exercise to do mocks with friends or colleagues in Microsoft to get a real sense of what the interview is actually like. Alternatively Prepfully has a ton of Microsoft Software Development Engineer In Test (SDET) experts who provide mock interviews - they provide incredible value at a great price. prepfully.com/practice-interviews