title-img


Bulk Shift Letters - Microsoft Top Interview Questions

You are given a lowercase alphabet string s and a list of integers shifts. Each element shifts[i] means to shift the first i + 1 letters of s by shifts[i] positions. Shifting a letter should wrap over "z" to "a". For example, shifting “z” by 2 results in “b”. Return the resulting string after applying shifts to s. Constraints 1 ≤ n ≤ 100,000 where n is the length of s and shifts Example 1 Input s = "afz" shifts = [1, 2, 1] Output "eia" Explanation We shif

View Solution →

Beer Bottles - Microsoft Top Interview Questions

You are given an integer n representing n full beer bottles. Given that you can exchange 3 empty beer bottles for 1 full beer bottle, return the number of beer bottles you can drink. Constraints 0 ≤ n < 2 ** 31 Example 1 Input n = 9 Output 13 Explanation In first round, we drink 9 beer bottles. We can exchange the 9 empty ones for 3 beer bottles. We can exchange the 3 empty ones for 1 beer bottle.

View Solution →

Split List - Microsoft Top Interview Questions

Given a list of integers nums, return whether you can partition the list into two non-empty sublists such that every number in the left sublist is strictly less than every number in the right sublist. Constraints n ≤ 100,000 where n is the length of nums. Example 1 Input nums = [5, 3, 2, 7, 9] Output True Explanation We can split the list into left = [5, 3, 2] and right = [7, 9]

View Solution →

Win After Last Round - Microsoft Top Interview Questions

You are given a list of integers nums of length n representing the current score of swimmers in a competition. There is one more round to swim and the first place winner for this round gets n points, second place n-1 points, etc. and the last place gets 1 point. Return the number of swimmers that can still win the competition after the last round. If you tie for first in points, this still counts as winning. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input

View Solution →

Word Machine - Microsoft Top Interview Questions

You are given a list of strings ops where each element is either: A non-negative integer that should be pushed into a stack "POP" meaning pop the top element in the stack "DUP" meaning duplicate the top element in the stack "+" meaning pop the top two and push the sum "-" meaning pop the top two and push top - second Return the top element in the stack after applying all operations. If there are any invalid operations, return -1. Constraints 1 ≤ n ≤ 100,000 wher

View Solution →