Skip to main content

Array

SpaceTime
AccessLookupInsertionDeletion
O(n)O(n)O(n)O(1)O(1)

Definition​

Array is a data structure that stores elements of the same type in contiguous memory locations, allowing for efficient indexing and retrieval.

Simplified

It's like organized row of storage bins where you can put similar items. Each bin has a number, making it easy to find and grab what you need quickly, helping to keep things neat and orderly.

Practice​

AspectPseudo Code
Reverse

Iterate array from the end to the start, appending each element to a new array

Slice

Creating a new list, then iterating from the start to stop index in the input array, adding each element to the new list

Concatenate

Combine two arrays into one by first copying elements from the first array, then appending elements from the second array to a new array