To the Top
File:  root - text - article - 2019 - 11 - word-search.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 781 Views, 13755 Search Bots | 136 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Amazon:

You are given a 2D array of characters, and a target string. Return whether or not the word target word exists in the matrix. Unlike a standard word search, the word must be either going left-to-right, or top-to-bottom in the matrix.

Example:


[['F', 'A', 'C', 'I'],
['O', 'B', 'Q', 'P'],
['A', 'N', 'O', 'B'],
['M', 'A', 'S', 'S']]


Given this matrix, and the target word FOAM, you should return true, as it can be found going up-to-down in the first column.

Here's the function signature:


def word_search(matrix, word):
# Fill this in.

matrix = [
['F', 'A', 'C', 'I'],
['O', 'B', 'Q', 'P'],
['A', 'N', 'O', 'B'],
['M', 'A', 'S', 'S']]
print word_search(matrix, 'FOAM')
# True
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Cateogry: Computing | 781 Views, 13755 Search Bots | 136 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Find the Number of Islands
  2. Daily Interview Problem: Product of Array Except Self
  3. Daily Interview Problem: Maximum Profit From Stocks
  4. [Daily Problem] Angles of a Clock
  5. Floor and Ceiling of a Binary Search Tree
  6. Daily Interview Question: Find Cycles in a Graph
  7. Daily Interview Question: Edit Distance
  8. Daily Interview Problem: Circle of Chained Words
  9. Longest Substring Without Repeating Characters
  10. Binary Tree Level with Minimum Sum

Comments (0)

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />