## Logically Consistent Book - Google Top Interview Questions

You are given a two-dimensional list of integers lists. Each element contains [start, end, type], meaning that from pages [start, end] inclusive, there's either an even number of words (type = 0) or an odd number of words (type = 1). Return whether lists is logically consistent. Constraints n ≤ 100,000 where n is the length of lists Example 1 Input lists = [ [1, 5, 1], [6, 10, 0], [1, 10, 0] ] Output False Explanation If there are an od

## Longest Arithmetic Sequence Tree Path - Google Top Interview Questions

You are given a binary tree root. Return the length of the longest path starting from a node that goes top to bottom where its values form an arithmetic sequence. An arithmetic sequence is a sequence of numbers where the difference between each consecutive two numbers is the same. For example, [2, 4, 6, 8] is an arithmetic sequence as is [1, 4, 7, 10]. A sequence of length two or fewer is considered an arithmetic sequence. Constraints 0 ≤ n ≤ 100,000 where n is the number of nodes in ro

## Longest Sublist with K Distinct Numbers - Google Top Interview Questions

Given an integer k and a list of integers nums, return the length of the longest sublist that contains at most k distinct integers. Constraints 0 ≤ k ≤ n ≤ 100,000 where n is the length of nums Example 1 Input k = 2 nums = [0, 1, 2, 1, 0] Output 3 Explanation The longest substring with 2 distinct integers is [1,2,1], which has length of 3. Example 2 Input k = 1 nums = [0, 0, 0, 0, 0] Output 5 Example 3 Input k = 1 nums = [0, 1, 2, 3

## Matrix Relations - Google Top Interview Questions

You are given an integer n and a two-dimensional list of integers relations. You want to fill an n by n matrix using relations, which defines the spatial ordering of some cell values in the matrix. Each element relations[i] contains (x, y, type) which means that x is left of y if type = 0 x is right of y if type = 1 x is above y if type = 2 x is below y if type = 3 Return the n by n matrix following the constraints in relations. Since some cells may not have a value, set it

## Maximal Expression - Google Top Interview Questions

Given a list of integers nums, return the maximal value that can be made by adding any binary operators +, -, and * between the numbers in nums as well as insert any valid brackets. Constraints 1 ≤ n ≤ 200 where n is the length of nums Example 1 Input nums = [-5, -3, -8] Output 64 Explanation We can make the following expression: (-5 + -3) * -8