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, 19747 Search Bots | 136 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 1113 Views, 19747 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, 19747 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: Merge Overlapping Intervals
- Fix Brackets
- [Daily Problem] Move Zeros
- Daily Interview Problem: Distribute Bonuses
- Daily Interview Problem: Buddy Strings
- Spectrum Master
- Daily Interview Question: Word Search
- Staying on a Chess Board
- Daily Interview Problem: Count Number of Unival Subtrees
- Longest Substring Without Repeating Characters
©2006~2024 SteakOverCooked - 0.00682 Seconds(s) - 2870.736 KB/s - 9 Online Memory: 493.73 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="index, 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 !