File: root - text - article - 2019 - 11 - word-search.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 1102 Views, 18564 Search Bots | 136 Words
| Browse | Archive
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, | English | Home Page | Category: Computing | 1102 Views, 18564 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 | 1102 Views, 18564 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
- Algorithm Interview Question: Find the Single Element in an Array of Duplicates
- Two-Sum
- Daily Interview Question: Longest Sequence with Two Unique Numbers
- Number of Ways to Climb Stairs
- New Vulnerabilities (CVE-2016-4581) have been detected in CentOS/RHEL/CloudLinux 7
- Daily Interview Problem: Largest BST in a Binary Tree
- Daily Interview Problem: First Missing Positive Integer
- Daily Interview Problem: Deepest Node in a Binary Tree
- Daily Interview Problem: Reverse Integer
- Consecutive Ones
©2006~2024 SteakOverCooked - 0.00896 Seconds(s) - 2207.264 KB/s - 29 Online Memory: 492.88 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 !