## Ascending Cards - Google Top Interview Questions

You are given a list of integers cards, and are looking to order the cards in a way so that they are revealed in ascending order. The cards are revealed in this manner: the top card is removed and revealed and then next card is moved to the back. This is repeated until there's no more cards. Return an ordering of the cards such that they are revealed in ascending order. Constraints n ≤ 100,000 where n is the length of cards Example 1 Input cards = [1, 2, 3, 4, 5] Output

View Solution →## Back to Front Linked List - Google Top Interview Questions

Given a singly linked list node, reorder it such that we take: the last node, and then the first node, and then the second last node, and then the second node, etc. Can you do it in \mathcal{O}(1)O(1) space? Constraints 0 ≤ n ≤ 100,000 where n is the number of nodes in node Example 1 Input node = [0, 1, 2, 3] Output [3, 0, 2, 1]

View Solution →## Ball Moves - Google Top Interview Questions

You are given a list of integers nums containing 0s and 1s where a 0 means the cell is empty and 1 means there's a ball there. Return a new list of integers A of the same length where A[i] is set to the total distance required to move all the balls to A[i]. The distance to move a ball in index j to index i is defined to be abs(j - i). Constraints n ≤ 100,000 where n is the length of nums Example 1 Input nums = [1, 1, 0, 1] Output [4, 3, 4, 5] Explanation A[0] = abs(

View Solution →## Bipartite Graph - Google Top Interview Questions

Given an undirected graph represented as an adjacency list, return whether the graph is bipartite. Constraints n, m ≤ 250 where n and m are the number of rows and columns in graph Example 1 Input graph = [ [1], [0] ] Output True Explanation This is bipartite since the node 1 can belong in set A and node 2 can belong in set B. Then the edges 0 - > 1 and 1 -> 0 has one node in A and one node in B Example 2 Input Visualize graph = [ [2,

View Solution →## Blocked Pipeline - Google Top Interview Questions

You are given an integer n and a two-dimensional list of integers requests. Consider a 2 x n matrix m where each cell can either be blocked or unblocked. It starts off as completely unblocked. Each element in requests contains [row, col, type] meaning that m[row][col] becomes blocked if type = 1 and it becomes unblocked if type = 0. You want to process requests one by one and after processing each one check whether there is an unblocked path from left to right. That is, whether you ca

View Solution →