文件: root - text - article - 2019 - 11 - word-search.txt
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 1102 次阅读, 18491 次搜索 | 136 个单词
| 浏览 | 博客存档
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 1102 次阅读, 18491 次搜索 | 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:
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:
标签: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | 英文 | 主页 | 类别: 计算机科学 | 1102 次阅读, 18491 次搜索 | 136 个单词 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: Count Number of Unival Subtrees
- Daily Interview Problem: Distribute Bonuses
- Daily Interview Problem: Circle of Chained Words
- [Daily Problem] Add two numbers as a linked list
- Daily Interview Problem: Min Range Needed to Sort
- Daily Interview Problem: Given two arrays, write a function to compute their intersection.
- Daily Interview Problem: Full Binary Tree
- Reverse a Directed Graph
- [Daily Problem] Move Zeros
- Algorithm Interview Question: Find the Single Element in an Array of Duplicates
©2006~2024 牛排过熟 - 0.01279 秒 - 1538.078 KB/s - 35 在线 内存: 494.03 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
牛排怎么做才好吃? | <meta name="机器人" content="索引, 跟踪">
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - 服务器 PHP 版本号: 7.4.33
评论 (0)
读写完全 - 一般 - 最小 - 表格 - 所有评论 - 统计
当前页暂时没有评论。