Microsoft | OA | March 2022
Summary
I completed the Microsoft Online Assessment in March 2022, solving two specific coding questions, and subsequently received an interview call.
Full Experience
I recently completed my online assessment for Microsoft in March 2022. The test lasted 90 minutes and consisted of three questions, though I could only recall two in detail. I found the assessment quite manageable and finished it efficiently, completing all solvable questions within 25 minutes. A particular aspect I noted was the absence of provided test cases; I had to write my own code, including basic and custom test cases, before submitting. Once submitted, no further changes were permitted. Following the assessment, I was happy to receive a call for an interview.
Interview Questions (2)
Write a function solution that, given a string S consisting of N letters 'a' and/or 'b', returns true when all occurrences of letter 'a' are before all occurrences of letter 'b' and returns false otherwise.
Examples:
- Given S = "aabbb", the function should return true.
- Given S = "ba", the function should return false.
- Given S = "aaa", the function should return true. Note that 'b' does not need to occur in S.
- Given S = "b", the function should return true. Note that 'a' does not need to occur in S.
- Given S = "abba", the function should return false.
Write an efficient algorithm for the following assumptions: N is an integer within the range [1..300,000]; string S consists only of the characters 'a' and/or 'b'.
Write a function class Solution { public int[] solution(int N); } that, given an integer N (1 <= N <= 100), returns an array containing N unique integers that sum up to 0. The function can return any such array.
For example, given N = 4, the function could return [1, 0, -3, 2] or [-2, 1, -4, 5]. The answer [1, -1, 1, 3] would be incorrect (because value 1 occurs twice). For N = 3 one of the possible answers is [-1, 0, 1] (but there are many more correct answers).