页面顶部 Top
文件:  root - text - article - 2019 - 11 - word-search.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 785 次阅读, 13885 次搜索 | 136 个单词

定阅此目录的博客 | 浏览 | 博客存档
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
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 785 次阅读, 13885 次搜索 | 136 个单词 定阅此目录的博客

猜您喜欢...

  1. How to Play WAV music under DOS?
  2. Daily Interview Problem: Buddy Strings
  3. Staying on a Chess Board
  4. Algorithm Interview: Shifted String
  5. First and Last Indices of an Element in a Sorted Array
  6. Daily Interview Problem: Merge List Of Number Into Ranges
  7. Autorun.inf Virus Protection
  8. Two-Sum
  9. Find the non-duplicate number
  10. Non-decreasing Array with Single Modification

评论 (0)

    当前页暂时没有评论。


最后更新: October 30 2020 14:21:12 | RSS Subscription
牛排怎么做才好吃? | <meta name="机器人" content="不索引, 跟踪" />