解題思路:廣度搜尋。每搜尋乙個,要把他所有連線的點放進列表,為避免重複,該點不被記錄
import numpy as np
w , l = input().split(' ')
w ,l = int(w), int(l)
in_list = np.zeros(shape=[w,l])
for i in range(w):
value = input().split(' ')
for j in range(l):
in_list[i][j] = int(value[j])
queue,all_list = ,
def get_sum(in_list,i,j,m,n):
queue,sum_list,in_list[i][j]=[[i,j]],in_list[i][j],0
while queue:
i, j = queue[0][0],queue[0][1]
if i>0 and j>0 and in_list[i-1][j-1] != 0:#左上
sum_list = sum_list + in_list[i-1][j-1]
in_list[i-1][j-1] = 0
if i>0 and in_list[i-1][j] !=0:#上
sum_list = sum_list + in_list[i-1][j]
in_list[i-1][j] = 0
if i>0 and j+10 and in_list[i+1][j-1] !=0:#左下
sum_list = sum_list + in_list[i+1][j-1]
in_list[i+1][j-1] = 0
if j>0 and in_list[i][j-1] !=0:#左
sum_list = sum_list + in_list[i][j-1]
in_list[i][j-1] = 0
del queue[0]
return sum_list
def main():
for i in range(w):
for j in range(l):
#print('所有值',all_list)
all_list.sort()
print('最小值',all_list[0])
print('最大值',all_list[-1])
if __name__ == 'main':
main()
2023年阿里巴巴演算法工程師實習招聘電面
除了訊號不是很好,電面的整體過程還算順利。問的問題也是基礎性的,畢竟是一面並沒有在專業提問上為難我。不過最多的精力是放在了開放性的問題上,真是刨根問底的問你啊。下面梳理一下整個過程吧。自我介紹 略基礎知識問答 說一下你了解的排序演算法。講一下快速排序的實現過程。說一下快速排序的缺點。如何改進排序演算...
阿里巴巴 2018秋招研發工程師筆試題
2.菜鳥倉庫是乙個很大很神奇的地方,各種琳琅滿目的商品整整齊齊地擺放在一排排貨架上,通常一種品類 sku 的商品會放置在貨架的某乙個格仔中,格仔設有統一的編號,方便工人們揀選。有一天沐哲去菜鳥倉庫參觀,無意中發現第1個貨架格仔編碼為1,第2 3個分別為1,2,第4 6個格仔分別是1,2,3,第7 1...
阿里巴巴工程師分享MySQL經驗
首先介紹下簡朝陽.現就職於阿里巴巴 中國 網路技術 dba team運維部,簡朝陽是本次mysql技術徵文大賽第三名得主 獲獎文章 mysql replication的實現原理 相信他的工作經驗肯定會對現在即將進入dba行業或者正在學習mysql技術的新人有所幫助。it168 這次mysql技術徵文...