PRACTICE

Code review practice

Each snippet below looks right and passes small tests, like much AI-written code. Find the faulty line and the kind of problem.

Exercise 1. Removing duplicates

This function returns the unique emails from sign-up data. It passes every test. Why does the API time out when the data is 1 million rows?

1. Click the faulty line.

2. What is the problem?

Exercise 2. A home-made binary search

This function finds a price in a sorted list. Almost every test passes, but one bug report says the page freezes for certain prices.

1. Click the faulty line.

2. What is the problem?

Exercise 3. Order report

This endpoint shows the 50 latest orders with their customers' names. Fast on a laptop, slow in production.

1. Click the faulty line.

2. What is the problem?