← All practice pages

Python

Python Lists & Tuples

Lists hold an ordered, changeable collection of values; tuples hold the same thing but cannot be changed after creation. Both are indexed from zero.

Try it now

Optimize a nested loop solution that finds all pairs in a list summing to a target. Replace the O(n²) approach with a set-based O(n) solution.

Create a free account to run your answer and get ARIA's review.