## Number of Fractions that Sum to 1 - Microsoft Top Interview Questions

You are given a list of lists fractions where each list contains [numerator, denominator] which represents the number numerator / denominator. Return the number of pairs of fractions there are that sums to 1. Constraints n ≤ 100,000 where n is the length of fractions Example 1 Input fractions = [ [1, 4], [2, 5], [3, 4], [3, 5], [5, 10], [1, 2], [1, 2] ] Output 5 Explanation 1/4 + 3/4, 2/5 + 3/5, 5/10 + 1/2, 5/10 +

## Minimum Updates to Make Bitwise OR Equal to Target - Microsoft Top Interview Questions

You are given three positive integers a, b and target. Consider an operation where you take either a or b and update one of the bits to 1 or to 0. Return the minimum number of operations required to make a | b = target. Constraints 1 ≤ a, b, target < 2 ** 31 Example 1 Input a = 2 b = 4 target = 8 Output 3 Explanation 10 = a 100 = b 1000 = target We need to first unset a and bs 1 bits to make them zero. Then we can set a directly to 8.

## Lossy Run-Length Encoding - Microsoft Top Interview Questions

You are given a lowercase alphabet string s and an integer k. Consider an operation where we perform a run-length encoding on a string by representing repeated successive characters as a count and character. For example, the string "aabbbc" would be encoded as "2a3bc". Note that we don't put "1c" for "c" since it only appears once successively. Given that you can first remove any k consecutive characters in s, return the minimum length possible of the resulting run-length encoding.

## Longest Strictly Increasing Then Decreasing Sublist - Microsoft Top Interview Questions

You are given a list of integers nums. Return the length of the longest sublist such that its length is at least 3 and its values are strictly increasing and then decreasing. Both the increasing part and the decreasing part must be non-empty. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [7, 1, 3, 5, 2, 0] Output 5 Explanation The sublist [1, 3, 5, 2, 0] is strictly increasing then decreasing. Example 2 Input nums = [

## Largest Kth Value of List - Microsoft Top Interview Questions

You are given integers n, total, and k. Consider a list of length n whose sum is total and where the absolute difference between any two consecutive numbers in the list is at most 1. Return the maximum value at index k of such a list. Constraints 1 ≤ n < 2 ** 31 0 ≤ k < n 0 ≤ total < 2 ** 31 Example 1 Input n = 3 total = 10 k = 1 Output 4 Explanation The largest such list is [3, 4, 3]. Example 2 Input n = 4 total = 10 k = 3 Output