Microsoft | OA | March 2022

microsoft logo
microsoft
Ongoing
April 17, 20223 reads

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)

Q1
Check if All 'a's Appear Before All 'b's
Data Structures & Algorithms

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:

  1. Given S = "aabbb", the function should return true.
  2. Given S = "ba", the function should return false.
  3. Given S = "aaa", the function should return true. Note that 'b' does not need to occur in S.
  4. Given S = "b", the function should return true. Note that 'a' does not need to occur in S.
  5. 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'.

Q2
N Unique Integers Sum Up to Zero
Data Structures & Algorithms

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

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!