## Nearest Bus Stop From a House - Google Top Interview Questions

You are given a two-dimensional integer matrix containing 0s, 1s, 2s, and 3s where 0 represents an empty cell 1 represents a wall 2 represents a house 3 represents a bus stop Return the shortest distance from any house to any bus stop. You can move up, down, left, and right but you can't move through a house or a wall cell. If there's no solution, return -1. Constraints n, m ≤ 250 where n and m are the number of rows and columns in matrix Example 1 Input matrix = [ [

## Next Node on Its Right - Google Top Interview Questions

You are given a binary tree root containing unique values, and an integer target. Find the node with value target and return the node that's directly right of it on its level. If the target node doesn't exist or if it's already in the rightmost position, return null. Constraints 0 ≤ n ≤ 100,000 where n is the number of nodes in root Example 1 Input Visualize tree = [1, [2, [4, null, null], [5, null, null]], [3, null, [6, [7, null, null], null]]] target = 5 Output

## Non-Overlapping Pairs of Sublists - Google Top Interview Questions

Given a list of integers nums and a positive integer k, return the number of pairs of non-overlapping sublists such that all the elements in each sublist have value greater than or equal to k. Mod the result by 10 ** 9 + 7. Constraints n ≤ 100,000 where n is the length of nums 1 ≤ k Example 1 Input nums = [3, 4, 4, 9] k = 4 Output 5 Explanation These are the pairs of sublists: [4], [9] [4], [9] (using other 4) [4], [4] [4, 4], [9] [4], [4,

## Number of Concatenations to Create Subsequence- Google Top Interview Questions

You are given two lowercase alphabet strings s and t. Return the minimum number of times we must concatenate s such that t is a subsequence of s. For example, if we concatenate "abc" three times, we'd get "abcabcabc". If it's not possible, return -1. Constraints 1 ≤ n ≤ 100,000 where n is the length of s 1 ≤ m ≤ 100,000 where m is the length of t Example 1 Input s = "dab" t = "abbd" Output 3 Explanation If we concatenate a = "dab" three times, we can get

## Number of Moves to Capture the King - Google Top Interview Questions

You are given a two-dimensional integer matrix board containing 0s, 1s and 2s representing some n x n chessboard. Each 0 represents an empty cell, 1 represents the knight and 2 represents the king. There is at least one knight but exactly one king. Given that the king stays still, return the minimum number of moves it would take for some knight to land on the king. If there's no solution, return -1. A knight can't land on another knight. Constraints 2 ≤ n ≤ 500 where n is th