Microsoft | OA | March 2022
- Result
- Ongoing
- Posted
- 17 Apr 2022
Summary
I completed the Microsoft Online Assessment in March 2022, solving two specific coding questions, and subsequently received an interview call.
How it went
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.
Questions asked (2)
- 01
Check if All 'a's Appear Before All 'b's
Data Structures & Algorithms
Write a function
solutionthat, given a stringSconsisting ofNletters 'a' and/or 'b', returnstruewhen all occurrences of letter 'a' are before all occurrences of letter 'b' and returnsfalseotherwise.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'.
- 02
N Unique Integers Sum Up to Zero
Data Structures & Algorithms
Write a function
class Solution { public int[] solution(int N); }that, given an integerN(1 <= N <= 100), returns an array containingNunique 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).