Code challenges help you build problem-solving skills, better understand the programming language you use, and get to know algorithms you may not be familiar with. If you want to improve your skills in programming, there's no better way than by writing code. In addition, coding challenges are convenient because they allow you to exercise your skills on a bite-sized problem and rarely require you to build a complete application, so you can usually complete them rather quickly.
Code challenges are also part of most coding interviews. Hiring managers may see the skills listed on your resume, and you may be able to talk like a programmer, but they also want to know that you can write code. By having you solve a coding challenge, they can assess your skills and be sure you can do the job. So working on coding challenges will also help you prepare for job interviews. We’ve collected 20 popular code challenges to get you started.
General programming challenges
While most code challenges are small in scope, that doesn’t mean they won’t involve a complex solution, so it is best to choose a challenge that stretches your skills but isn’t completely out of your league. Below, we’ve ranked a few coding challenges by their complexity so you can find the best challenge for your skill level.
Basic code challenges
These are good beginner challenges. They may not actually show up in a coding interview, but everyone has to start somewhere. These challenges are good for practicing your skills at using a programming language.
- Build a binary search tree.
- Write a program that prints the numbers from 1 to 100. But for multiples of three, print Fizz instead of the number, and multiples of five, print Buzz. For numbers that are multiples of both three and five, print FizzBuzz.
- Print Hello World in several different ways in a programming language.
- Code in a new language.
- Write a function that will take a given string and reverse the order of the words.
- Write a function that will find the 50th number in the Fibonacci Sequence.
- Write a function that tests if a number, n, is a prime number.
Intermediate code challenges
These code challenges are examples of what might be asked in interviews. There may be a big difference in difficulty compared to the basic challenges. If you get stuck on these, go back to the basics, practice more, and you will get there.
- Write a function to check that a binary search tree is balanced.
- Write a function to reverse the order of words that have punctuation and keep the punctuation in place.
- Given two words (beginWord and endWord) and a dictionary’s word list, find the length of the shortest transformation sequence from beginWord to endWord.
- Write a function that will find the nth number in the Fibonacci Sequence.
- Write a function that will print out all prime numbers in a given string.
Hard code challenges
The point of these challenges is to challenge you, which will help you learn more. These will be similar to the type of work you'll do on the job. Most of these challenges will be hard but use Big O notation and expect a certain type of performance. If you are struggling with these, search StackOverflow or Google for direction. Many developers have run into these types of problems and will help you find the solution. Just don’t cheat and copy the answer. What good would that do?
- Write a function that inserts a list of n numbers into a binary search tree that runs at O(n log n) time.
- Write a function to reverse the order of words with punctuation and keep the punctuation in place that runs at 0(n) time.
- Write a function that will find the nth number in the Fibonacci Sequence and runs at O(n) time.
- Write a function that tests if a number, n, is a prime number and a function that will print out all prime numbers in a given string as efficiently as possible.
Technology specific challenges
If you want to try some coding challenges that will test your skills on specific technologies, we have a few of those challenges.
Web development code challenges
- Recreate a magazine layout using Semantic HTML and CSS Flexbox. It is not always that easy to recreate a design. This code challenge will really test your skills with HTML and CSS by having you recreate a design from scratch on your own. Once you are a working web developer, you will be doing this daily.
Financial data analysis code challenges
- Basic: Given the daily values of a stock, write a program that will find how you can gain the most with a single buy-sell-trade.
- Intermediate: Given the daily values of a stock over several days n, write a program that will find how you can gain the most with a combination of buy-sell trades.
- Hard: Complete both the basic and intermediate algorithms in the most efficient way possible.
Code challenges are a great way to practice your coding skills or keep yourself from getting rusty. Building complete applications will also teach you a lot, but they can take time to finish. On the other hand, a coding challenge can be completed in an evening and will expose you to new algorithms and programming concepts. They are also part of many coding interviews, so completing a few can help you prepare for a job interview. For more details on the code challenges we have, check out Essential Information on Code Challenges.