Intersection of Two Linked Lists,Search a 2D Matrix,Set Matrix Zeroes,Combinations,Spiral Matrix

Intersection of Two Linked Lists

簡單鏈表,此題解法很多,題目要求不能改變原始鏈表結構,那麼就只能遍歷到結尾,時間O(m+n)即可,空間可以O(1)


Search a 2D Matrix

兩次二分搜索而已


Set Matrix Zeroes

既然是直接修改矩陣,可以利用矩陣的第一行和第一列做記錄,這樣就不需要額外開闢空間,空間複雜度爲O(1)即可解決


Combinations

遞歸可以,非遞歸也可(可畫出構成樹)


Spiral Matrix I,II
簡單數組操作

發佈了68 篇原創文章 · 獲贊 0 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章