title-img


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 →

K-Distinct Groups - Google Top Interview Questions

You are given a list of integers counts where counts[i] represents the number of items that exist of type i. You are also given an integer k. Return the maximum number of groups of size k we can have given that each group must have items of distinct types. Constraints n ≤ 100,000 where n is the length of counts k ≤ n Example 1 Input counts = [3, 3, 2, 5] k = 2 Output 6 Explanation Let's name the four item types [a, b, c, d] respectively. We can have the

View Solution →

K Stack Pops - Google Top Interview Questions

You are given two-dimensional list of integers stacks and an integer k. Assuming each list in stacks represents a stack, return the maximum possible sum that can be achieved from popping off exactly k elements from any combination of the stacks. Constraints n ≤ 500 where n is the number of rows in stacks. m ≤ 200 where m is the maximum number of elements in a stack. k ≤ 100 Example 1 Input stacks = [ [100, -3, -10], [1], [4, 5, 6] ] k = 4 Ou

View Solution →

Kth Last Node of a Linked List - Google Top Interview Questions

Given a singly linked list node, return the value of the kth last node (0-indexed). k is guaranteed not to be larger than the size of the linked list. This should be done in \mathcal{O}(1)O(1) space. Constraints n ≤ 100,000 where n is the length of node Example 1 Input node = [1, 2] k = 1 Output 1 Explanation The second last node has the val of 1 Example 2 Input node = [0, 1, 2, 3] k = 2 Output 1

View Solution →

Kth User to Visit Website- Google Top Interview Questions

You are given a two-dimensional list of integers requests and an integer k. Each element requests[i] contains [start, end] representing an inclusive interval for the possible times when user i visited the website. Each user visits the site exactly once. Return the users who may have been the kth (0-indexed) user to visit the site, sorted in ascending order. You can assume that the site can serve an unlimited number of users at any time. Constraints 1 ≤ n ≤ 100,000 where n is the

View Solution →