Easy problems, step by step

The next step after the basics: you write one function, and the tests call it. Each section practises one idea a few times, so by the end you have seen the tools that most problems are built from.

Challenges
25
Easy
25
Start the list

Walking through an array

One pass, keeping track of what you have seen so far.

StatusChallengeLevelSave
1.Plus OneAdd one to a number stored as an array of digits.Easy
2.Move ZerosMove every zero to the end, keeping the other numbers in order.Easy
3.Missing NumberFind the one number missing from 0 to n.Easy
4.Best Time to TradePick one day to buy and a later day to sell for the biggest profit.Easy

Strings

Compare, scan and convert text.

StatusChallengeLevelSave
5.Valid PalindromeCheck whether text reads the same both ways, ignoring case and punctuation.Easy
6.Longest Common PrefixFind the longest start that every word shares.Easy
7.Roman to IntegerTurn a Roman numeral into a number.Easy
8.First Unique CharacterFind the first letter that appears only once.Easy

Counting with a hash map

Remember counts or positions to answer in one pass.

StatusChallengeLevelSave
9.Contains DuplicateCheck whether any number appears twice.Easy
10.Two SumFind the two positions whose numbers add up to a target.Easy
11.Valid AnagramCheck whether one word is a rearrangement of another.Easy
12.Majority ElementFind the value that fills more than half of the array.Easy

Two pointers, searching and stacks

Move two positions at once, halve the search, and match pairs.

StatusChallengeLevelSave
13.Merge Sorted ArraysMerge two sorted arrays into one sorted array.Easy
14.Squares of a Sorted ArraySquare every number of a sorted array and keep it sorted.Easy
15.Binary SearchFind a number's position in a sorted array in log time.Easy
16.Valid ParenthesesCheck that every bracket is closed by the right kind, in the right order.Easy

Math, bits and a first recursion

Digits, binary, and a problem built from smaller copies of itself.

StatusChallengeLevelSave
17.Palindrome NumberCheck whether a number's digits read the same both ways.Easy
18.Count Set BitsCount the 1s in a number's binary form.Easy
19.Single NumberEvery number appears twice except one; find it.Easy
20.Climbing StairsCount the ways to climb n stairs taking one or two at a time.Easy

Linked lists and trees

Nodes that point to other nodes: relink a list, then walk a tree.

StatusChallengeLevelSave
21.Reverse a Linked ListTurn a linked list around so its last node comes first.Easy
22.Middle of a Linked ListFind the middle node of a linked list in one pass.Easy
23.Merge Two Sorted ListsJoin two sorted linked lists into one sorted list.Easy
24.Depth of a TreeCount the levels of a binary tree, from the root to its deepest leaf.Easy
25.Invert a TreeMirror a binary tree, swapping every node's left and right children.Easy