## Half Monotonous String - Google Top Interview Questions

You are given a lowercase alphabet string s of even length consisting of lowercase alphabet letters. Return the minimum number of characters that need to be updated such that one of the following three conditions is true for all 0 ≤ i < n/2 and n/2 ≤ j < n: s[i] > s[j] or s[i] < s[j] or s[i] == s[j] Constraints 0 ≤ n ≤ 100,000 where n is the length of s Example 1 Input s = "aa" Output 0 Explanation This string already meets the s[i] == s[j] condition Exam

View Solution →## Hill Maker - Google Top Interview Questions

You are given a two-dimensional list of integers matrix where matrix[r][c] represents the height of that cell. You are currently at top left corner and want to go to the bottom right. You can move to nearby cells (up, down, left, right) only if the neighboring cell's height is less than or equal to the current cell's height. Given that you can increase the height of any number of cells before you move, return the minimum total height that needs to be increased so that you can go to the bot

View Solution →## H-Index - Google Top Interview Questions

In academia, the h-index is a metric used to calculate the impact of a researcher's papers. It is calculated as follows: A researcher has index h if at least h papers have at least h citations each. If there are multiple h satisfying this formula, the maximum is chosen. Given a list of paper citations of a researcher citations, calculate their h-index. Constraints n ≤ 100,000 where n is the length of citations Example 1 Input citations = [4, 3, 0, 1, 5] Output 3 Explanation At

View Solution →## Hotel Room Assignments - Google Top Interview Questions

You are given a two-dimensional list of integers intervals where intervals[i] contains two numbers start and end representing a half-open interval [start, end). Each element represents requested times for a hotel room. Hotel rooms are assigned at the time that the booking starts. If requests intervals[i] and intervals[j] have the same starting time, then earlier index min(i, j) is assigned a room first. We assign rooms starting from 0 and in general use the smallest non-negative integ

View Solution →## Interval Painting - Google Top Interview Questions

You are given a list of integers walks and an integer target. You are currently at position 0 in a one-dimensional line. Each integer abs(walks[i]) represents the number of steps taken. Positive value means you walked right while negative value means you walked left. We define a "block" as an interval of length 1 that has been walked on. For example, if you walk right 2 times, then you walked on blocks [0, 1] and [1, 2] once each. If you walk left once, then you'd walk on

View Solution →