title-img


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 →

Count Nodes in Complete Binary Tree - Google Top Interview Questions

Given a complete binary tree root, return the number of nodes in the tree. This should be done in \mathcal{O}((\log n)^2)O((logn) 2 ). Constraints n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [1, [2, [4, null, null], [5, null, null]], [3, null, null]] Output 5 Example 2 Input root = [1, [2, [4, null, null], [5, null, null]], [3, [6, null, null], [7, null, null]]] Output 7

View Solution →