title-img


Count Rectangular Submatrices - Google Top Interview Questions

Given a two-dimensional list of integers matrix containing 1s and 0s, return the total number of submatrices with all 1 s. Constraints n, m ≤ 250 where n and m are the number of rows and columns in matrix. Example 1 Input matrix = [ [1, 1, 0], [1, 1, 0], [0, 0, 0] ] Output 9 Explanation There's four 1 x 1 matrices. Theres two 2 x 1 matrices. There's two 1 x 2 matrices. And there's one 2 x 2 matrix.

View Solution →

Count Submatrices That Sum Target - Google Top Interview Questions

You are given a two-dimensional integer matrix and an integer target. Return the number of submatrices in matrix whose sum equals target. Constraints 0 ≤ n, m ≤ 100 where n and m are the number of rows and columns in matrix Example 1 Input matrix = [ [0, -1], [0, 0] ] target = 0 Output 5 Explanation We have three 1 x 1 submatrices, one 2 x 1 submatrix and one 1 x 2 submatrix.

View Solution →

Decode Messages Sequel - Google Top Interview Questions

Given the mapping a = 1, b = 2, ... z = 26, as well as "*" which can be mapped anything from 1 to 9, and an encoded message message (as a string), count the number of ways it can be decoded. Mod the result by 10 ** 9 + 7. Constraints n ≤ 100,000 where n is the length of message Example 1 Input message = "1*" Output 18 Explanation The "*" can represent anything from 1 to 9, so this can be decoded as: ["aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai"] - (1,

View Solution →

Delete Integers In Ascending Order - Google Top Interview Questions

You are given a list of unique integers nums and want to delete each number in ascending order. Return the indices of numbers in order of their deletion. Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [3, 5, 1, 4, 2] Output [2, 3, 0, 1, 0] Explanation We delete the numbers in this order: Delete 1 at index 2 and now we have [3, 5, 4, 2] Delete 2 at index 3 and now we have [3, 5, 4] Delete 3 at index 0 and now we have [5, 4]

View Solution →

Fix Flight Itinerary - Google Top Interview Questions

You are given a list of uppercase alphabet strings itinerary and a two-dimensional list of uppercase alphabet strings edges. itinerary contains the list of airports you visited in order but the airport names may be misspelled. Each element in edges contains [source, dest] meaning there is a flight that goes from source to dest. Every airport has the same length of 3. Return the minimum number of characters you can change in itinerary such that the itinerary becomes valid. You can

View Solution →