title-img


Blocked Pipeline - Google Top Interview Questions

You are given an integer n and a two-dimensional list of integers requests. Consider a 2 x n matrix m where each cell can either be blocked or unblocked. It starts off as completely unblocked. Each element in requests contains [row, col, type] meaning that m[row][col] becomes blocked if type = 1 and it becomes unblocked if type = 0. You want to process requests one by one and after processing each one check whether there is an unblocked path from left to right. That is, whether you ca

View Solution →

Blocks to Spell Word - Google Top Interview Questions

You are given a list of lowercase alphabet strings words and a string target. Assuming you can pick at most one character from each string in words, return whether you can spell out target in any order. Constraints n ≤ 12 where n is the length of target m ≤ 12 where m is the length of words Example 1 Input words = ["how", "do", "i", "shot", "web"] target = "wow" Output True Explanation We can pick "w" from "how", "o" from "do" and "w" from "web". Example 2

View Solution →

Brick Layout - Google Top Interview Questions

You are given a list of integers bricks and integers width and height. Each bricks[i] represents a 1 x bricks[i] size brick. Return the number of ways to lay the bricks such that we get full layout of bricks with width width and height height. Bricks can be reused but can only be laid horizontally. Answer fits within 32-bit integer. Constraints 1 ≤ n ≤ 1,000 where n is the length of bricks 1 ≤ width * n ≤ 100,000 Example 1 Input bricks = [2, 3] width = 5 height = 2

View Solution →

Cluster Management - Google Top Interview Questions

You are given two lists of integers cores and tasks. Each cores[i] represents the number of cores available in server i. And each tasks[i] represents the number of cores needed to run that task. Each task can be run in only one server but each server can run multiple tasks. Return whether it's possible to run all the tasks with the given cores. Constraints n ≤ 15 where n is the length of cores m ≤ 15 where m is the length of tasks Example 1 Input cores = [8, 10] tas

View Solution →

Connect Sticks - Google Top Interview Questions

You are given a two-dimensional list of integers sticks. Each element in the list represents a stick with two ends, and has two numbers between [1, 6] representing each end. You can connect two sticks together if any of their ends are equal. The resulting stick's ends become the leftover ends and its length is incremented. Return the length of the longest stick possible. Constraints n ≤ 10 where n is the length of sticks. Example 1 Input sticks = [ [1, 2], [1, 3],

View Solution →