Fundamentals
/
Constant vs Linear Time
⏸
00:00
↻
← Prev
Next →
▶
Question
Implement getFirst(arr) which returns the first element in O(1) time, and getLast(arr) which returns the last element in O(1) time. Return [first, last].
▶
My Code
▶
Reference Solution