title-img


Longest Prefix Sequence - Google Top Interview Questions

You are given a list of lowercase alphabet strings words. Return the length of the longest sequence of words where each previous word is the prefix of the next word and the next word has just one new character appended. You can rearrange words in any order. Constraints 0 ≤ n ≤ 100,000 where n is the length of words 1 ≤ m ≤ 100,000 where m is the length of the longest string in words Example 1 Input words = ["abc", "ab", "x", "xy", "abcd"] Output 3 Explanation

View Solution →

Longest Repeating Substring - Google Top Interview Questions

Given a lowercase alphabet string s, return the length of the longest substring that occurs at least two times in s. If there's no such string, return 0. Constraints 0 ≤ n ≤ 1,000 where n is the length of s Example 1 Input s = "abcdzabcd" Output 4 Explanation The longest substring that occurs more than once is "abcd". Example 2 Input s = "abcdefg" Output 0 Explanation There's no repeating substring.

View Solution →

Look and Say - Google Top Interview Questions

The "look and say" sequence is defined as follows: beginning with the term 1, each subsequent term visually describes the digits appearing in the previous term. The first few terms are as follows: 1 11 <- 1 one 21 <- 2 ones 1211 <- 1 two, 1 one 111221 <- 1 one, 1 two, 2 ones 312211 <- 3 ones, 2 twos, 1 one Given an integer n, return the nth term of this sequence as a string. Constraints 1 ≤ n ≤ 40 Example

View Solution →

Make a Palindrome by Inserting Characters - Google Top Interview Questions

Given a string s, return the minimum number of characters needed to be inserted so that the string becomes a palindrome. Constraints n ≤ 1,000 where n is the length of s Example 1 Input s = "radr" Output 1 Explanation We can insert "a" to get "radar"

View Solution →

Maximize the Minimum Value After K Sublist Increments- Google Top Interview Questions

You are given a list of integers nums and integers size and k. Consider an operation where we take a contiguous sublist of length size and increment every element by one. Given that you can perform this operation k times, return the largest minimum value possible in nums. Constraints n ≤ 100,000 where n is the length of nums k < 2 ** 31 Example 1 Input nums = [1, 4, 1, 1, 6] size = 3 k = 2 Output 2 Explanation We can increment [1, 4, 1] to get [2, 5, 2,

View Solution →