面試題 :相鄰兩數最大差值

其實就是能夠當作一個桶排序,每一個桶裏面只須要存一個最大值和一個最小值便可,A空...B B的最大值-A的最小值就是一個潛在的最大差值,由於還可能存在C空...D的狀況,這裏也有一個差值,比較這些差值誰大便可。ios #include<iostream> #include<vector> #include<algorithm> using namespace std; class Gap { pu
相關文章
相關標籤/搜索