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, 13823 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, 13823 Search Bots | 136 Words Subscribe to Feed Burner

Related Articles

  1. Daily Interview Problem: Sort Colors
  2. Autorun.inf Virus Protection
  3. Algorithm Interview: Shifted String
  4. Daily Interview Question: Word Search
  5. Daily Interview Problem: Merge K Sorted Linked Lists
  6. Daily Interview Problem: Group Words that are Anagrams
  7. ImageMagick Vulnerabilities -  CVE-2016–3714
  8. Spreadsheet Columns
  9. Most Frequent Subtree Sum
  10. PHP Unit Tests on VPS Server

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    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" />