我知道Javascript中的unshift()和push()方法有什么区别,但我想知道时间复杂度有什么不同?
我想push()方法是O(1),因为你只是在数组末尾添加一个项目,但我不确定unshift()方法,因为,我想你必须"移动"所有其他现有的元素向前,我想是O(log n)或O(n)?
javascript arrays time complexity-theory push
arrays ×1
complexity-theory ×1
javascript ×1
push ×1
time ×1