Arrays Flashcards
What is an array?
Arrays are a data structure that hold the same type of data in contiguous memory locations.
What is a subarray?
A range of contiguous values within an array.
For example
[1,2,3,4]
a subarray is [2,3]
What is a subsequent in an array?
A sequence is derived from the given sequence by deleting some or no elements without changing the oder of the remaining element.
given an array [2, 3, 6, 1, 5, 4], [3, 1, 5] is a subsequence but [3, 5, 1] is not a subsequence.
What is the time complexity of an array
?
Search is O(n), if it is sorted then O(log(n))
slicing takes O(n)
What are should you do during in a interview if there you are given an array?
Clarify if there are duplicates, if so would it make it easier or harder question.
What are the array corner cases?
Empty Sequence
Sequence of 1 or 2 elements
Sequences with repeated elements
Duplicate values in the sequence