File: root - text - article - 2019 - 11 - word-search.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 1113 Views, 19963 Search Bots | 136 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 1113 Views, 19963 Search Bots | 136 Words
| Browse | Archive
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:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Cateogry: Computing | 1113 Views, 19963 Search Bots | 136 Words 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
Related Articles
- Daily Interview Problem: Trapping Rainwater
- Print a tree level-by-level, with line-breaks
- [Daily Problem] Course Prerequisites
- Algorithm Interview: Longest Consecutive Sequence
- Daily Interview Problem: Arithmetic Binary Tree
- Consecutive Ones
- Daily Interview Problem: Room scheduling
- Algorithm Interview: Subarray With Target Sum
- Floor and Ceiling of a Binary Search Tree
- Daily Interview Problem:Create a balanced binary search tree
©2006~2024 SteakOverCooked - 0.0062 Seconds(s) - 8650.611 KB/s - 50 Online Memory: 527.65 KB
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Comments (0)
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !