## Largest Tree Sum Path - Google Top Interview Questions

Given a binary tree root, return the largest sum of any path between any two nodes. Constraints n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [-6, [5, null, null], [4, [7, [4, [2, null, null], null], [8, null, null]], [12, null, null]]] Output 31 Explanation The largest sum path is: [8, 7, 4, 12]

View Solution →## Lazy Run-Length Decoding - Google Top Interview Questions

Implement a data structure RunLengthDecoder which implements the following methods: RunLengthDecoder(string s) which takes a string s that is run-length encoded. string value(int i) which returns the character at index i of the run-length decoded version of s. string valueInRange(string c, int i, int j) which returns the first lowercase alphabet character that is greater than or equal to c from the range [i, j) of the decoded string. You can assume that the range contains characters

View Solution →## Leaf Pairs Less Than Target Distance Away - Google Top Interview Questions

You are given a binary tree root and an integer target. Return the number of pairs of leaves such that the shortest distance between them is less than or equal to target. Constraints 0 ≤ n, target ≤ 1,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]] target = 2 Output 1 Explanation The pair (4, 5) meet the distance criteria since the distance between them is 2. Example 2 Input root

View Solution →## Lexicographically Smallest Leaf to Root Path- Google Top Interview Questions

Given a binary tree root containing digits from 0 to 9, return the lexicographically smallest leaf to root path. Constraints n ≤ 100,000 where n is the number of nodes in root Example 1 Input root = [1, [8, null, null], [7, [4, [6, null, null], [3, null, null]], [5, null, null]]] Output [3, 4, 7, 1]

View Solution →## List Consecutive Split - Google Top Interview Questions

Given a list of integers nums, and an integer k, return whether the list can be split into lists where each list contains k integers and is consecutively increasing. Constraints n ≤ 100,000 where n is the length of nums. Example 1 Input nums = [3, 2, 3, 4, 5, 1] k = 3 Output True Explanation We can split the list into [1, 2, 3] and [3, 4, 5]

View Solution →