title-img


Stuck Keyboard- Google Top Interview Questions

You are given two strings typed and target. You want to write target, but the keyboard is stuck so some characters may be written 1 or more times. Return whether it's possible that typed was meant to write target. Constraints n ≤ 100,000 where n is the length of typed m ≤ 100,000 where n is the length of s Example 1 Input typed = "aaabcccc" target = "abc" Output True Explanation Each of the "a", "b", and "c" were typed Example 2 Input typed = "abc"

View Solution →

Target Number with Operations - Google Top Interview Questions

Given positive integers start and end (start < end), return the minimum number of operations needed to convert start to end using these operations: Increment by 1 Multiply by 2 Constraints start < end < 2 ** 31 Example 1 Input start = 2 end = 9 Output 3 Explanation We can multiply 2 to get 4, and then again to get 8, then add 1 to get 9.

View Solution →

Toeplitz Matrix - Google Top Interview Questions

Given a two-dimensional matrix of integers matrix, determine whether it's a Toeplitz matrix. A Toeplitz is one where every diagonal descending from left to right has the same value. Constraints n, m ≤ 250 where n and m are the number of rows and columns in matrix Example 1 Input matrix = [ [0, 1, 2], [3, 0, 1], [4, 3, 0], [5, 4, 3] ] Output True Example 2 Input matrix = [ [1, 0, 0], [0, 0, 0], [0, 0, 1] ]

View Solution →

Ambigram Detection- Google Top Interview Questions

You are given a lowercase alphabet string s and a two-dimensional list of strings pairs. Each element in pairs contains [a, b] meaning that character a and b are considered equivalent. We say that if a and b are equivalent and b and c are equivalent, then a and c are also equivalent. Also, any character a is equivalent to itself. Return whether s is a palindrome given the equivalence relations. Constraints 0 ≤ n ≤ 100,000 where n is the length of s 0 ≤ p ≤ 100,000 where p is th

View Solution →

Arithmetic Sequence Queries ☃️ - Google Top Interview Questions

You are given a list of integers nums and a two-dimensional list of integers queries. Each element in queries contains [i, j] and asks whether the sublist of nums from [i, j], inclusive, is an arithmetic sequence. Return the number of queries that are true. Constraints 0 ≤ n ≤ 100,000 where n is the length of nums 0 ≤ m ≤ 100,000 where m is the length of queries Example 1 Input nums = [1, 3, 5, 7, 6, 5, 4, 1] queries = [ [0, 3], [3, 4], [2, 4] ]

View Solution →