该网站上有一个播客:https://www.glennbeck.com/st/podcast
这是播客中的图片之一
class Solution:
def findDiagonalOrder(self, matrix: 'List[List[int]]') -> 'List[int]':
from collections import deque
if(len(matrix) == 0 or len(matrix[0]) == 0):
return []
if(len(matrix) == 1):
return matrix[0]
res = []
if(len(matrix[0]) == 1):
for row in matrix:
res+=row
return res
r, c = 0, 0
root = (r, c)
rows, cols = len(matrix), len(matrix[0])
step = 0
queue = deque([root])
left = []
#forwards
while queue and step < rows:
step += 1
size = len(queue)
for _ in range(size):
r, c = queue.popleft()
left.append(matrix[r][c])
if r == 0:
level = [(i, step -i) for i in range(step+1)] #(r, c+1)
elif c == 0:
level = [(step-i, i) for i in range(step+1)]
queue += level
#logging.debug(f"queue: {queue}")
#logging.debug(f"left: {left}")
#raise Exception
#backwords
step = 0
queue = deque([root])
right = []
#forwards
while queue and step < rows-1:
step += 1
size = len(queue)
for _ in range(size):
r, c = queue.popleft()
right.append(matrix[rows-r-1][cols-c-1])
if r == 0:
level = [(i, step -i) for i in range(step+1)] #(r, c+1)
elif c == 0:
level = [(step-i, i) for i in range(step+1)]
queue += level
#logging.debug(f"queue: {queue}")
#logging.debug(f"right: {right}")
#raise Exception
right.reverse()
res = left + right
return res
您会注意到size = Large附加在图片网址上。
但是,如果我查看此页面https://www.glennbeck.com/st/podcast的页面源,我可以看到他们在播客播放器中使用了此类链接:
notice size =图片网址很小
他们从哪里得到这样的图像大小的信息?我没有在上方的播客网址中看到此信息。