Pular para o conteúdo principal

13 documentos selecionados com "matrix"

Ver todas os Marcadores

Friend Circles

This question is asked by Facebook. You are given a two dimensional matrix, friends, that represents relationships between coworkers in an office. If friendsi = 1 then coworker i is friends with coworker j and coworker j is friends with coworker i. Similarly if friendsi = 0 then coworker i is not friends with coworker j and coworker j is not friend with coworker i. Friendships in the office are transitive (i.e., if coworker one is friends with coworker two and coworker two is friends with coworker three, coworker one is also friends with coworker three). Given the friendships in the office defined by friends, return the total number of distinct friends groups in the office.

Largest Pond Size

You are given a two-dimensional matrix that represents a plot of land. Within the matrix there exist two values: ones which represent land and zeroes which represent water within a pond. Given that parts of a pond can be connected both horizontally and vertically (but not diagonally), return the largest pond size.

Max Area of Island

Given a 2D array grid, where zeroes represent water and ones represent land, return the size of the largest island.

Minimum Path Sum

This question is asked by Google. Given an N×M matrix, grid, where each cell in the matrix represents the cost of stepping on the current cell, return the minimum cost to traverse from the top-left hand corner of the matrix to the bottom-right hand corner.

Number of Islands

Given a 2D array of integers with ones representing land and zeroes representing water, return the number of islands in the grid.

Number of Ships in Harbor

You're about to set sail off a pier and first want to count the number of ships that are already in the harbor. The harbor is deemed safe to sail in if the number of boats in the harbor is strictly less than limit. Given a 2D array that presents the harbor, where O represents water and S represents a ship, return whether or not it's safe for you to set sail.

Path with Maximum Gold

This question is asked by Amazon. Given a 2D matrix that represents a gold mine, where each cell's value represents an amount of gold, return the maximum amount of gold you can collect given the following rules:

Rabbit Holes Distance

Given a 2D array containing only the following values: -1, 0, 1 where -1 represents an obstacle, 0 represents a rabbit hole, and 1 represents a rabbit, update every cell containing a rabbit with the distance to its closest rabbit hole.

Rotate Image

Given an image represented as a 2D array of pixels, return the image rotated 90 degrees clockwise.

Spiral Matrix

Given a 2D matrix, return a list containing all of its elements in spiral order.

Word Search

This question is asked by Amazon. Given a 2D board that represents a word search puzzle and a string word, return whether or the given word can be formed in the puzzle by only connecting cells horizontally and vertically.