Question Bank

Array Fundamentals Quiz

Difficulty: Easy

Quick prompts on indexing, in-place mutation, and the cost of common array operations. Good for warming up before sliding-window or two-pointer drills.

Question Bank
/

Array Fundamentals Quiz

Array Fundamentals Quiz

Quick prompts on indexing, in-place mutation, and the cost of common array operations. Good for warming up before sliding-window or two-pointer drills.

Question Bank
Easy
JavaScript
4 questions
arrays
data-structures
quiz
fundamentals

979 views

16

What does this snippet print and why? Identify the cost of each line in Big-O.

Examples

Example 1:

Input: a = [10, 20, 30, 40, 50]; read a[2], a.length, push 60, read a[a.length - 1]
Output: 30, then 5, then 60
Explanation: a[2] is an O(1) index read (30). a.length is O(1) cached (5). push appends 60 in amortized O(1), and the new last element is 60.