页面顶部 Top
文件:  root - text - article - 2019 - 11 - word-search.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 781 次阅读, 13516 次搜索 | 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, | 英文 | 主页 | 类别: 计算机科学 | 781 次阅读, 13516 次搜索 | 136 个单词 定阅此目录的博客

猜您喜欢...

  1. Find Pythagorean Triplets
  2. Daily Interview Problem: Validate Binary Search Tree
  3. Daily Interview Problem: Spiral Traversal of Grid
  4. [Daily Problem] Remove k-th Last Element From Linked List
  5. YES!!
  6. Daily Interview Problem: Count Number of Unival Subtrees
  7. Algorithm Interview: Subarray With Target Sum
  8. Daily Interview Problem: Tree Serialization
  9. 56 Bytes
  10. Algorithm Interview Question: H-Index

评论 (0)

    当前页暂时没有评论。


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