Lists and Sets
LockedLesson 17 of 60 · DataStructures · Medium
Finish these first:Arrays →Generics →Or pass the tests below to unlock it now.
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.
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.
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?
Your challenge
Write static List<Integer> uniqueSorted(List<Integer> xs).
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.