Arrays — Easy
Quiz
Array basics
Quick sanity check on indexing, complexity and the two-pointer pattern.
5 questions
- Q01multiple choiceWhat is the time complexity of finding the maximum element in an unsorted array of n integers?
- Q02multiple choiceWhy does the standard 'second largest' algorithm need to track BOTH the largest and the second largest in the same loop?
- Q03multiple choiceAn array is sorted in non-decreasing order if for every adjacent pair a[i-1] and a[i], it holds that ...
- Q04fill in the blankIn the in-place 'remove duplicates from a sorted array' algorithm, the two pointers are usually called 'read' and 'write'. After the loop finishes, the new length of the unique-values prefix is _____ + 1.
- Q05fill in the blankIn the 'move zeros to end' algorithm, we use a _____ operation rather than a copy because we also need to push the existing zero somewhere to the right.