File: root - text - article - 2019 - 11 - spiral-traversal-of-grid.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 441 Views, 18804 Search Bots | 90 Words
| Browse | Archive
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 441 Views, 18804 Search Bots | 90 Words
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Hi, here's your problem today. This problem was recently asked by Amazon:
By the way, check out our NEW project AlgoPro (http://algopro.com) for over 60+ video coding sessions with ex-Google/ex-Facebook engineers.
You are given a 2D array of integers. Print out the clockwise spiral traversal of the matrix.
Example:
The clockwise spiral traversal of this array is:
Here is a starting point:
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 441 Views, 18804 Search Bots | 90 Words By the way, check out our NEW project AlgoPro (http://algopro.com) for over 60+ video coding sessions with ex-Google/ex-Facebook engineers.
You are given a 2D array of integers. Print out the clockwise spiral traversal of the matrix.
Example:
grid = [[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20]]
The clockwise spiral traversal of this array is:
1, 2, 3, 4, 5, 10, 15, 20, 19, 18, 17, 16, 11, 6, 7, 8, 9, 14, 13, 12
Here is a starting point:
def matrix_spiral_print(M):
# Fill this in.
grid = [[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14, 15],
[16, 17, 18, 19, 20]]
matrix_spiral_print(grid)
# 1 2 3 4 5 10 15 20 19 18 17 16 11 6 7 8 9 14 13 12
![Subscribe to Feed Burner Subscribe to Feed Burner](/images/form/rss.gif)
Related Articles
- Daily Interview Puzzle: Minimum Size Subarray Sum
- Daily Interview Problem: Arithmetic Binary Tree
- Daily Interview Problem: Spiral Traversal of Grid
- Spreadsheet Columns
- Kaprekar
- Palindrome Integers
- [Daily Problem] Longest Palindromic Substring
- Algorithm Interview: Convert Roman Numerals to Decimal
- Most Frequent Subtree Sum
- Daily Interview Problem: Merge List Of Number Into Ranges
©2006~2024 SteakOverCooked - 0.00975 Seconds(s) - 2069.459 KB/s - 24 Online
Memory: 492.41 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" />
![](/images/top.jpg)
18:54:01 up 13 days, 18:33, 2 users, load average: 0.98, 0.86, 0.73 - Server PHP Version: 7.4.33
Read & Write - Normal - Mini - Post - All Comments - Statistics
Be the first one to comment this page !