Practice problems

Choose a topic, work through an example, and reveal a hint or worked answer when you’re ready.

Showing 61–80 of 145 problems

JS

Optional chaining and missing values

What value does the expression produce?

Intermediate
JS

Closures and private function state

What does b return on its first call?

Advanced
JS

Objects, prototypes, and this

Which object does this refer to inside label?

Advanced
JS

The event loop and microtasks

What order do the logs appear in?

Advanced
JS

Iterables and generators

What array does [...generator()] produce?

Advanced
JS

Web workers and message passing

Which side should update the heading with the total?

Advanced
JS

Memory and event listener cleanup

What should happen when the view closes?

Advanced
JS

Coordinating multiple promises

In what order do the results appear?

Advanced
DS

Arrays and prefix sums

Find the sum of the supplied zero-based interval. Include both endpoints.

Beginner
DS

Big O and growth

Two independent loops each visit every item in a list. Count the total visits and give the time bound.

Beginner
DS

Linear search

Find the first shelf position with the requested label. Use zero-based indexing and -1 for a missing label.

Beginner
DS

Binary search

A library shelf displays sorted copy numbers. Return the zero-based index of a requested number, or -1 if the copy is absent.

Beginner
DS

Bubble sort

Show the array after exactly one full pass of bubble sort, starting on the left.

Beginner
DS

Stacks and undo

Read the top value after performing the listed operations, or return "Empty".

Beginner
DS

Queues and arrival order

List the jobs removed in order. Return "Empty" for a removal when no job is waiting.

Beginner
DS

Two pointers

Which distinct pair reaches the target?

Beginner
DS

Sliding windows

What is the largest window sum?

Beginner
DS

Singly linked lists

Insert B after A and report the resulting node order.

Intermediate
DS

Hash maps and counting

Return the first label seen a second time, or "None" if all labels are unique.

Intermediate
DS

Recursion and tree traversal

Count all nodes in each tree. A missing child contributes zero.

Intermediate