Time Complexity · #44 · 2026-05-18
What's the Big-O?
TypeScript ·Difficulty 1/3
How to play
Read the code and pick its time complexity from four Big-O choices. Think about loops, recursion, and hidden costs. Press 1–4 or click to answer.
n = arr.length. What is the SPACE complexity (excluding the input)?
function reverseInPlace<T>(arr: T[]): T[] {
let left = 0;
let right = arr.length - 1;
while (left < right) {
[arr[left], arr[right]] = [arr[right], arr[left]];
left++;
right--;
}
return arr;
}
Loading your progress...
Press 1 through 4, or tap a numbered choice, to answer. Back to hub