GCGrowCarrer

Lists and Sets

Locked

Lesson 17 of 60 · DataStructures · Medium

Finish these first:Arrays →Generics →Or pass the tests below to unlock it now.

1

The big idea

List (ordered) — ArrayList, LinkedList. Set (unique) — HashSet, LinkedHashSet, TreeSet.

Think of it like this: Think of data structures as specialized toolboxes: a List keeps items in numbered slots (`0, 1, 2...`), a Set keeps only unique badges, and a Dictionary/Map labels each compartment with a custom name key.
Key words (tap to learn):
2

Read the lesson

List (ordered) — ArrayList, LinkedList. Set (unique) — HashSet, LinkedHashSet, TreeSet. Program to the interface.

List<Integer> xs = new ArrayList<>(List.of(3, 1, 2));
Collections.sort(xs);
Set<Integer> seen = new HashSet<>(xs);

List.of(...) is immutable.

3

Quick check

Before writing code: What should `Solution.uniqueSorted(java.util.List.of(3,1,3,2))` return when your implementation of Lists and Sets is working?

4

Your challenge

2 sample tests, 1 hidden

Write static List<Integer> uniqueSorted(List<Integer> xs).

Stuck? Get a hint (free)
More learning tools(compare languages, visual guide, related lessons)

Compare with another language

Similar to javascript.arrays-lists (86% overlap). Dynamic contiguous arrays: Array in JS, std::vector in C++, slices []T in Go, Vec<T> in Rust.

Visual walkthrough

A diagram, a step-by-step animation, and short captions for Lists and Sets.

Mastery0%