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

猜您喜欢...

  1. Daily Interview Problem: Group Words that are Anagrams
  2. Most Frequent Subtree Sum
  3. Non-decreasing Array with Single Modification
  4. Algorithm Interview Question: Max and Min with Limited Comparisons
  5. Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
  6. [Daily Problem] Angles of a Clock
  7. CPU Utilization
  8. [Daily Problem] Move Zeros
  9. Daily Interview Problem:Create a balanced binary search tree
  10. Daily Interview Problem: Reconstrunct Binary Tree from Preorder and Inorder Traversals

评论 (0)

    当前页暂时没有评论。


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