2.Data Structures: Arrays 學習筆記
Published in
Jul 17, 2021
學習資料來源: Master the Coding Interview: Data Structures + Algorithms
【Data Structures: Arrays】
優點
1.快速找到目標
2.快速push/pop新項目
3.資料經過排序
缺點
1.inserts/deletes較慢(因為需要shift剩餘項目)
2.固定長度(發生在static arrays,不會發生在使用dynamic arrays的程式語言)
範例
【用JS實作 Array】
【練習: Reverse String】
ex: ‘Hi My name is Claire’ should be: ‘erialC si eman yM iH’
=> 用陣列處理string相關問題
【練習: Sorted Arrays】
ex: [0,3,4,31], [4,6,30] should be: [0, 3, 4, 4, 6, 30, 31]
回到筆記列表,文章中的內容如果有誤,歡迎提醒告知,謝謝!