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

猜您喜欢...

  1. Daily Interview Problem: Largest Product of 3 Elements I
  2. Absolute Path
  3. Algorithm Interview: Permutations of numbers
  4. Reverse a Linked List
  5. Daily Interview Problem: Min Range Needed to Sort
  6. Daily Interview Problem: Sort Colors
  7. Daily Interview Problem: Given two arrays, write a function to compute their intersection.
  8. Daily Interview Problem: Arithmetic Binary Tree
  9. Windows Scripting
  10. Algorithm Interview: Convert Roman Numerals to Decimal

评论 (0)

    当前页暂时没有评论。


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