Microsoft OA Fair Indexes Solution

Microsoft Online Assessment 2021 Questions and Solution

Microsoft OA Fair Indexes Solution You are given two arrays A and B consisting of N integers each. Index K is named fair if the four sums (A[0] + … + A[K-1]), (A[k] + … + A[N-1]), (B[0] + … + B[k-1]) and (B[K] + … + B[N-1]) are all equal. In other words, K is the index where the two arrays, A and B, can be split (into two non-empty arrays each) in … Read more

Microsoft OA Jump Game Solution

Microsoft Online Assessment 2021 Questions and Solution

Microsoft OA Jump Game Solution You are given an array of non-negative integers arr and a start index. When you are at an index i, you can move left or right by arr[i]. Your task is to figure out if you can reach value 0. Also See: Microsoft Online Assessment Questions and Solution Example 1: Input: arr = [3, 4, 2, 3, 0, … Read more

Microsoft OA Widest Path Without Trees Solution

Microsoft Online Assessment 2021 Questions and Solution

Microsoft OA Widest Path Without Trees Solution There are N trees (numbered from 0 to N-1) in a forest. The K-th tree is located at coordinates (X[K], Y[K]). We want to build the widest possible vertical path, such that there is no tree on it. The path must be built somewhere between a leftmost and a rightmost tree, which means that the width … Read more

Microsoft OA Arithmetic Slices Solution

Microsoft Online Assessment 2021 Questions and Solution

Microsoft OA Arithmetic Slices Solution An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same. For example, [1,3,5,7,9], [7,7,7,7], and [3,-1,-5,-9] are arithmetic sequences. Given an integer array nums, return the number of arithmetic subarrays of nums. A subarray is a contiguous subsequence of the array. Also See: Microsoft Online Assessment Questions … Read more

Microsoft OA Particle Velocity Solution

Microsoft Online Assessment 2021 Questions and Solution

Microsoft OA Particle Velocity Solution You are a programmer in a scientific team doing research into particles. As an experiment, you have measured the position of a single particle in N equally distributed moments of time. The measurement made in moment K is recorded in an array particles as particles[K]. Now, your job is to count all the periods of time when … Read more