Coding challenges in Python, JavaScript, and SQL
Each challenge is a problem, a solution you write and a set of tests it passes or fails. They are sorted by Big-O, from the most direct ones to what you get asked in an interview. Pick one, read the problem and solve it in your browser: there is nothing to install.
O(1) · Trivial
71 challenges · Free- 2000 was last centurySQL · filtering · comparisons
- An afternoon readSQL · filtering · comparisons
- Area of a rectanglePython · JavaScript · operations
- Celsius to FahrenheitPython · JavaScript · operations · decimals
- Closest to the targetPython · JavaScript · conditionals · comparisons · operations
- Coat or t-shirt?Python · JavaScript · conditionals · strings · comparisons
- Did the fever go down?Python · JavaScript · lists · indexes · booleans
- Did they pass the class?Python · JavaScript · booleans · conditionals
- Digits the other way roundPython · JavaScript · digits · operations
- Do the two times overlap?Python · JavaScript · conditionals · booleans · comparisons
- Does it fall in range?Python · JavaScript · conditionals · booleans · comparisons
- Does the photo fit the envelope?Python · JavaScript · lists · conditionals · booleans
- Filed under LSQL · strings · filtering
- Fits on the spineSQL · strings · filtering
- How far apartPython · JavaScript · operations · comparisons
- How far from free shippingPython · JavaScript · operations · conditionals
- How far off is it?Python · JavaScript · conditionals · comparisons · operations
- How many blocks you walkPython · JavaScript · lists · indexes · operations
- How many days in the month?Python · JavaScript · lists · conditionals
- InitialsPython · JavaScript · strings
- Is it a leap year?Python · JavaScript · conditionals · booleans
- Is it even?Python · JavaScript · operations · booleans
- Is it isosceles?Python · JavaScript · lists · conditionals · booleans
- Is it the same text?Python · JavaScript · strings · booleans
- Is the big bottle worth it?Python · JavaScript · operations · booleans
- Last name firstPython · JavaScript · strings
- Minutes to hoursPython · JavaScript · operations · strings
- Nobody sings for themSQL · strings · filtering
- Out past midnightSQL · filtering · comparisons
- Ribbon around the framePython · JavaScript · operations
- Same letter at both ends?Python · JavaScript · strings · booleans
- Sunday through SaturdaySQL · filtering · comparisons
- Swap the endsPython · JavaScript · strings · indexes
- The 2011sSQL · filtering · strings
- The afternoon sessionSQL · filtering
- The area of the platePython · JavaScript · operations · decimals
- The average without the worstPython · JavaScript · lists · indexes · decimals
- The bill with the tipPython · JavaScript · operations · decimals
- The boxes you needPython · JavaScript · operations · division
- The candy left in the bagPython · JavaScript · operations · division
- The cards I getPython · JavaScript · operations · division · conditionals
- The date written outPython · JavaScript · lists · indexes · strings
- The eggs that shipPython · JavaScript · operations · division
- The final gradePython · JavaScript · operations · decimals
- The first and last stopPython · JavaScript · lists · indexes · strings
- The hypotenusePython · JavaScript · operations · decimals
- The larger of twoPython · JavaScript · conditionals
- The last characterPython · JavaScript · strings
- The last digitPython · JavaScript · operations · digits
- The last fourPython · JavaScript · strings · indexes
- The letter gradePython · JavaScript · conditionals · strings · comparisons
- The letters left overPython · JavaScript · strings · operations
- The middle letterPython · JavaScript · strings · indexes
- The name, written rightPython · JavaScript · strings
- The nearest tenPython · JavaScript · operations · division
- The percentage you got rightPython · JavaScript · operations · division · decimals
- The seats still freePython · JavaScript · operations · division
- The shortened textPython · JavaScript · strings · conditionals
- The sign of a numberPython · JavaScript · conditionals · comparisons
- The song in secondsPython · JavaScript · strings · operations
- The tax already in the pricePython · JavaScript · operations · decimals
- The tiles that fitPython · JavaScript · operations · division
- The twelve-hour clockPython · JavaScript · conditionals · strings
- The usernamePython · JavaScript · strings
- Those go, and only thoseSQL · filtering
- Three for the price of twoPython · JavaScript · operations · division
- Twelve months and a bonusSQL · operations · filtering
- Two exams, added up wrongSQL · filtering
- What the host paysPython · JavaScript · operations · division
- What time will it be?Python · JavaScript · operations · division
- What you need on the last examPython · JavaScript · operations
O(log n) · Easy
38 challenges · Free- A power of 2?Python · JavaScript · loops · operations · booleans
- A through LSQL · comparisons · conditionals · sorting
- A ticket by textSQL · nulls · filtering
- Binary searchPython · JavaScript · lists · search · loops
- Count the digitsPython · JavaScript · loops · operations
- Digits to number the pagesPython · JavaScript · digits · operations · loops
- Each aisle gets its own discountSQL · conditionals · operations · decimals
- Not passed yetSQL · conditionals · nulls
- Room for one badgeSQL · conditionals
- Split the thousandsPython · JavaScript · strings · digits · loops
- The ad with no pairPython · JavaScript · lists · search · indexes
- The beacons that are missingPython · JavaScript · lists · search · indexes
- The catches of the same weightPython · JavaScript · lists · search · indexes
- The display case backupSQL · sorting · filtering
- The eighties, the ninetiesSQL · operations · sorting
- The first broken buildPython · JavaScript · lists · search · booleans
- The gates of the canalPython · JavaScript · dictionaries · search · lists
- The growing colonyPython · JavaScript · division · loops
- The key of the dayPython · JavaScript · digits · comparisons · loops
- The last night counts tooSQL · operations · conditionals
- The lighthouse in binaryPython · JavaScript · division · strings
- The lockers in usePython · JavaScript · division · digits · loops
- The lucky ticketPython · JavaScript · digits · booleans · loops
- The mailbags that pile upPython · JavaScript · operations · search · loops
- The nearest stopPython · JavaScript · lists · search · comparisons
- The one-digit oraclePython · JavaScript · digits · loops
- The section a page belongs toPython · JavaScript · lists · search · indexes
- The square plotsPython · JavaScript · division · search · operations
- The supply shipsPython · JavaScript · division · search · loops
- The three closestSQL · sorting · conditionals
- The top of the ridgePython · JavaScript · lists · search · comparisons
- The turn in the tapePython · JavaScript · lists · search · comparisons
- The way the clerk walksSQL · sorting · conditionals
- The workshop hits the roadSQL · sorting · nulls
- Tournament roundsPython · JavaScript · division · loops
- What's still out goes firstSQL · sorting · nulls
- Who signs off on my day off?SQL · nulls · sorting
- Youngest firstSQL · sorting
O(n) · Medium
93 challenges · Full plan- A steady beatPython · JavaScript · lists · loops · booleans
- A two-credit 10SQL · grouping · joins · decimals
- Add up the evensPython · JavaScript · loops · lists
- Aisle by aisleSQL · grouping · conditionals
- Are they balanced?Python · JavaScript · strings · lists · loops · booleans
- Atoms in the formulaPython · JavaScript · strings · loops
- Averages that mean somethingSQL · grouping · joins
- Bunched up or spread outSQL · grouping · joins · sorting
- Chairs for parents' nightSQL · grouping · joins · sorting
- Compress the textPython · JavaScript · strings · loops
- Connecting flightsPython · JavaScript · strings · lists · booleans
- Count the vowelsPython · JavaScript · strings · loops
- Count the wordsPython · JavaScript · strings · loops
- Crossed alibisPython · JavaScript · lists · indexes · comparisons
- Even numbers in even placesPython · JavaScript · lists · loops · indexes
- File namesPython · JavaScript · strings · conditionals · loops
- From binary to a numberPython · JavaScript · strings · loops
- Full barsPython · JavaScript · lists · loops · booleans
- Game to elevenPython · JavaScript · strings · loops · conditionals
- High tidesPython · JavaScript · lists · indexes · comparisons
- Hit comboPython · JavaScript · strings · loops
- How many linesPython · JavaScript · strings · loops · conditionals
- How many payrolls does it cover?SQL · grouping · joins · decimals
- How many servingsPython · JavaScript · lists · division · loops
- Initials of a phrasePython · JavaScript · strings · lists
- Interleaved ordersPython · JavaScript · lists · indexes · loops
- Is it a palindrome?Python · JavaScript · strings · loops · booleans
- Is it a pangram?Python · JavaScript · strings · loops · booleans
- Is the ISBN valid?Python · JavaScript · strings · loops · booleans
- Jumping across platformsPython · JavaScript · lists · booleans · loops
- Lead changesPython · JavaScript · strings · loops · conditionals
- Level by experiencePython · JavaScript · lists · loops · conditionals
- Not the priciest, not the biggestSQL · grouping · joins
- Pages carried homeSQL · grouping · joins · decimals
- Pendulum crossingsPython · JavaScript · lists · loops · comparisons
- Reverse the textPython · JavaScript · strings · loops
- Roman numeralsPython · JavaScript · strings · indexes · comparisons
- Rum for the voyagePython · JavaScript · lists · loops
- Same book twice doesn't countSQL · grouping · sorting
- Spices between portsPython · JavaScript · lists · loops · comparisons
- Square root by handPython · JavaScript · loops · operations · search
- Stock at closing timePython · JavaScript · dictionaries · lists · loops
- Sum of multiplesPython · JavaScript · loops · lists · division
- The 250 ClubSQL · grouping · joins · decimals
- The balanced potionPython · JavaScript · lists · loops · indexes
- The book club roundPython · JavaScript · dictionaries · loops
- The burnt cookiesPython · JavaScript · lists · loops
- The busiest pair of cornersPython · JavaScript · dictionaries · lists · comparisons
- The butcher's tallyPython · JavaScript · strings · regular expressions · operations
- The cart totalPython · JavaScript · lists · loops
- The diver's logPython · JavaScript · strings · loops
- The divisor that fits them allPython · JavaScript · lists · loops · operations
- The doubled wordPython · JavaScript · strings · loops
- The echo spellPython · JavaScript · strings · digits · loops
- The fake doubloonPython · JavaScript · lists · indexes · loops
- The fastest kilometerPython · JavaScript · lists · loops · indexes
- The favorite facePython · JavaScript · lists · loops · indexes
- The fewest transfersPython · JavaScript · dictionaries · sets · loops
- The health barPython · JavaScript · lists · loops · conditionals
- The hidden runePython · JavaScript · strings · booleans · loops
- The itinerary in the ticketsPython · JavaScript · dictionaries · sets · lists
- The keyboard with backspacePython · JavaScript · strings · loops · indexes
- The largest in the listPython · JavaScript · lists · loops
- The launch windowPython · JavaScript · lists · loops · indexes
- The list averagePython · JavaScript · lists · loops · decimals
- The longest wordPython · JavaScript · strings · lists · loops
- The mirror cipherPython · JavaScript · strings · loops
- The missing bandPython · JavaScript · lists · operations
- The most typical satellitePython · JavaScript · lists · indexes · comparisons
- The notebook by the registerSQL · grouping · joins
- The recipe's timePython · JavaScript · strings · division · loops
- The rover heading homePython · JavaScript · strings · loops
- The sailboat's headingPython · JavaScript · lists · loops · conditionals
- The scrambled messagePython · JavaScript · strings · sorting · lists
- The shape of the melodyPython · JavaScript · lists · strings · comparisons
- The shelf that settlesPython · JavaScript · grids · strings · indexes
- The strong passwordPython · JavaScript · strings · booleans · loops
- The strongest signalPython · JavaScript · lists · loops · indexes
- The stuck sensorPython · JavaScript · lists · loops
- The tiered tributePython · JavaScript · lists · loops · decimals
- The torn-out table of contentsPython · JavaScript · strings · regular expressions · lists
- The twin keysPython · JavaScript · strings · loops · indexes
- The unclosed doorsPython · JavaScript · strings · loops
- The vault combinationPython · JavaScript · lists · loops · booleans
- The winning numberPython · JavaScript · dictionaries · lists · loops
- The wizards' duelPython · JavaScript · lists · loops · comparisons
- Two half mapsPython · JavaScript · strings · conditionals · loops
- Wave setsPython · JavaScript · lists · loops · conditionals
- What the team makesSQL · grouping · joins · decimals
- Where are the books from?SQL · grouping · joins · sorting
- Where do our orders come from?SQL · grouping · joins · nulls
- Where there's more than oneSQL · grouping · nulls
- Who owes grades?SQL · grouping · joins · nulls
O(n log n) · Hard
67 challenges · Full plan- Are they consecutive?Python · JavaScript · lists · sorting · booleans
- As many shows as you canPython · JavaScript · lists · strings · sorting
- Beach umbrellasPython · JavaScript · lists · sorting · comparisons
- Both, not eitherSQL · sets · subqueries
- Empty-handedSQL · subqueries · nulls · grouping
- Entry, mid, and highSQL · grouping · conditionals · sorting
- Inventory SaturdaySQL · subqueries · grouping · joins
- Is it an isogram?Python · JavaScript · strings · sorting · booleans
- Loose endsSQL · sets · subqueries · nulls
- Neighbors who don't know itSQL · joins · nulls
- New facesSQL · subqueries · grouping · joins
- New year, new pageSQL · sets · sorting · nulls
- News to DenverSQL · subqueries · joins
- Not on the rosterSQL · subqueries · joins · grouping
- Numbers that arrived as textPython · JavaScript · lists · sorting · strings
- Often ordered togetherSQL · joins · grouping
- One student, one voteSQL · subqueries · grouping
- Portions for the dinersPython · JavaScript · lists · sorting · loops
- Probes before the deadlinePython · JavaScript · lists · sorting · booleans
- Report cards read acrossSQL · joins · grouping · conditionals
- Routes with no repeatsPython · JavaScript · lists · sorting · loops
- Sold only oncePython · JavaScript · lists · sorting · loops
- Sort by lengthPython · JavaScript · lists · sorting · strings
- Sort the lettersPython · JavaScript · strings · sorting · lists
- Spent nothing, still on the listSQL · joins · nulls · grouping
- The alternating choirPython · JavaScript · lists · sorting · indexes
- The anagrams of a wordPython · JavaScript · strings · lists · sorting
- The busiest bandPython · JavaScript · sorting · lists · indexes
- The cars that stay putPython · JavaScript · lists · sorting · division
- The cheapest billPython · JavaScript · sorting · lists · indexes
- The easy gradersSQL · subqueries · sets · joins
- The flipping spellsPython · JavaScript · sorting · lists · conditionals
- The galleon's holdPython · JavaScript · strings · sorting · loops
- The game shopPython · JavaScript · sorting · loops · comparisons
- The hallway listSQL · joins · grouping · sorting
- The height of the sawPython · JavaScript · lists · search · comparisons
- The hives kept apartPython · JavaScript · lists · sorting · search
- The jersey numbersPython · JavaScript · lists · sorting · loops
- The kindergarten potsPython · JavaScript · dictionaries · sorting · indexes
- The largest numberPython · JavaScript · lists · sorting · digits
- The lifeboatsPython · JavaScript · lists · sorting · comparisons
- The longest straightPython · JavaScript · lists · sorting · loops
- The medianPython · JavaScript · lists · sorting · decimals
- The most voted and the least votedPython · JavaScript · lists · sorting · loops
- The price you cannot payPython · JavaScript · sorting · loops
- The primes up to nPython · JavaScript · lists · loops · operations
- The researcher's scorePython · JavaScript · lists · sorting · comparisons
- The sacks before the rainPython · JavaScript · lists · search · division
- The same coins?Python · JavaScript · lists · sorting · booleans
- The shortest gapPython · JavaScript · strings · sorting · division
- The smallest differencePython · JavaScript · lists · sorting · loops
- The station platformsPython · JavaScript · lists · sorting · loops
- The temple beamsPython · JavaScript · lists · sorting · comparisons
- The three crystalsPython · JavaScript · lists · sorting · operations
- The top three scoresPython · JavaScript · lists · sorting · loops
- The torches on the wallPython · JavaScript · lists · sorting · decimals
- The trough that never runs dryPython · JavaScript · lists · search · loops
- The watched hoursPython · JavaScript · strings · lists · sorting
- The witnesses' clocksPython · JavaScript · lists · sorting · comparisons
- Their latest, front and centerSQL · subqueries · joins
- Trailing their own teamSQL · subqueries · nulls
- Two at a timeSQL · joins · nulls · comparisons
- What can I take home?SQL · subqueries · nulls · joins
- What every supplier carriesPython · JavaScript · sets · lists · sorting
- What sells and what sitsSQL · joins · grouping
- Who waits the leastPython · JavaScript · lists · sorting · loops
- Who's the boss around here?SQL · joins · grouping
O(n²) · Very hard
78 challenges · Full plan- A day that works for bothPython · JavaScript · lists · loops · booleans
- A line for every daySQL · recursion · dates · window functions
- Arriving WednesdaySQL · dates · conditionals
- Best day yetSQL · window functions · grouping · subqueries
- Candy at summer campPython · JavaScript · lists · loops · comparisons
- Chain of gemsPython · JavaScript · strings · loops · indexes
- Days until warmerPython · JavaScript · lists · loops · indexes
- Don Chuy's pancakesPython · JavaScript · loops · lists · indexes
- First with lastSQL · window functions · joins · grouping
- How soon they're backSQL · window functions · dates · grouping
- In a row, in orderPython · JavaScript · lists · loops · booleans
- January off the shelfSQL · dates · nulls · grouping
- Lighthouse, TheSQL · strings · conditionals · sorting
- One raise, not twoSQL · changing data · conditionals
- Out of every 100 in payrollSQL · window functions · decimals
- Paige is leavingSQL · changing data · subqueries
- Pairs out of orderPython · JavaScript · lists · loops
- Pairs that add upPython · JavaScript · lists · loops
- Pairs that are k apartPython · JavaScript · lists · loops
- Past dueSQL · dates · nulls · joins
- Power for liftoffPython · JavaScript · lists · loops
- Rain between the rocksPython · JavaScript · lists · loops · comparisons
- Roles that never meetPython · JavaScript · sets · lists · sorting
- Samples in the capsulesPython · JavaScript · comparisons · loops · lists
- Starting at the bottomSQL · changing data · subqueries
- Starts and ends the samePython · JavaScript · strings · loops
- The antennas that see each otherPython · JavaScript · comparisons · loops · lists
- The best run of the seasonPython · JavaScript · lists · loops
- The birthday cluesPython · JavaScript · loops · lists · indexes
- The buses that went byPython · JavaScript · lists · comparisons · conditionals
- The cartographer's tablePython · JavaScript · conditionals · loops · lists
- The change at the registerPython · JavaScript · lists · loops · indexes
- The closest strainsPython · JavaScript · strings · lists · loops
- The coach's shoutsPython · JavaScript · loops · lists · strings
- The coded telegramPython · JavaScript · booleans · loops · strings
- The colliding particlesPython · JavaScript · lists · loops · comparisons
- The color codePython · JavaScript · lists · loops · conditionals
- The fence on the streetPython · JavaScript · comparisons · loops · lists
- The first one that never repeatsPython · JavaScript · strings · loops
- The game of tic-tac-toePython · JavaScript · grids · conditionals · loops
- The golem clashPython · JavaScript · lists · loops · comparisons
- The khan's horsesPython · JavaScript · comparisons · loops · lists
- The lamplighter's roundPython · JavaScript · comparisons · loops · lists
- The last one in the circlePython · JavaScript · lists · loops · division
- The library forgetsSQL · changing data · subqueries
- The loneliest seatPython · JavaScript · strings · indexes · comparisons
- The longest climbPython · JavaScript · lists · loops
- The magician's shufflePython · JavaScript · lists · indexes · loops
- The next rung upSQL · window functions · subqueries
- The oasis caravanPython · JavaScript · division · loops · lists
- The palindrome inscriptionPython · JavaScript · strings · loops · indexes
- The penguin linePython · JavaScript · conditionals · loops · lists
- The puddles in the yardPython · JavaScript · grids · recursion · loops
- The pyramid of glassesPython · JavaScript · decimals · loops · lists
- The register, day by daySQL · window functions · grouping · conditionals
- The ring lockPython · JavaScript · strings · loops · indexes
- The routes past the roadworksPython · JavaScript · recursion · grids · dictionaries
- The sail between two mastsPython · JavaScript · lists · loops · comparisons
- The signal that comes backPython · JavaScript · lists · indexes · loops
- The snail's shellPython · JavaScript · strings · loops · indexes
- The sphinx's digitsPython · JavaScript · digits · strings · indexes
- The Talavera borderPython · JavaScript · strings · loops · indexes
- The terracotta rowPython · JavaScript · lists · loops · indexes
- The theme comes backPython · JavaScript · lists · loops · indexes
- The third stampSQL · window functions · joins · dates
- The three sacksPython · JavaScript · lists · sorting · loops
- The tiles on the rackPython · JavaScript · loops · lists · strings
- The tournament joustsPython · JavaScript · comparisons · loops · lists
- The tune with no repeated notesPython · JavaScript · strings · loops
- The twelve-knot ropePython · JavaScript · loops · operations · lists
- The twin codicesPython · JavaScript · loops · strings · indexes
- The warriors of CadmusPython · JavaScript · lists · loops · comparisons
- The wasp nests in the nurseryPython · JavaScript · grids · strings · loops
- The week of the 4thSQL · dates · grouping · strings
- What went out todaySQL · changing data · subqueries · nulls
- Which day do we close?SQL · dates · grouping · conditionals
- Yang Hui's trianglePython · JavaScript · operations · loops · lists
- You started with a KeyboardSQL · window functions · joins
O(2ⁿ) · Legendary
35 challenges · Full plan- A fully covered night shiftPython · JavaScript · recursion · lists · strings
- Ariadne's threadPython · JavaScript · recursion · lists · loops
- Can I borrow your notes?SQL · subqueries · joins · grouping
- Clash-free rhythmsPython · JavaScript · recursion · strings · lists
- Frank against everyoneSQL · recursion · joins
- Grandma's game piecePython · JavaScript · recursion · lists · indexes
- Grandpa's spoonsPython · JavaScript · recursion · lists · indexes
- Lilavati's sumsPython · JavaScript · recursion · strings · indexes
- Mansa Musa's bags of goldPython · JavaScript · recursion · lists · indexes
- Modules on rocketsPython · JavaScript · recursion · lists · booleans · division
- Monday's operating roomsPython · JavaScript · recursion · lists · comparisons
- Not one more, not one lessSQL · window functions · operations
- Spelling with elementsPython · JavaScript · recursion · strings · indexes
- Splitting the honeyPython · JavaScript · recursion · lists · comparisons
- The block partyPython · JavaScript · recursion · lists · loops
- The board cutsPython · JavaScript · recursion · lists · dictionaries
- The capsule's cargo holdPython · JavaScript · recursion · lists · comparisons
- The chain of commandSQL · recursion · strings
- The emptiest shelfSQL · window functions · dates · sets
- The Hansa votesPython · JavaScript · recursion · lists · comparisons
- The hidden motifPython · JavaScript · recursion · strings · indexes
- The houses of XibalbaPython · JavaScript · recursion · lists · loops
- The lab switchesPython · JavaScript · recursion · lists
- The morning batchesPython · JavaScript · recursion · lists · dictionaries
- The necklace both threads sharePython · JavaScript · recursion · strings · indexes
- The Pompeii graffitoPython · JavaScript · recursion · strings · indexes
- The rowers of PuntPython · JavaScript · recursion · lists · comparisons
- The salary in the middleSQL · window functions · grouping
- The satellite's counterweightsPython · JavaScript · recursion · lists · operations
- The store on a streakSQL · window functions · dates
- The subway routesPython · JavaScript · recursion · lists · loops
- The two-pan balancePython · JavaScript · recursion · lists · operations
- The Winters oneSQL · recursion · strings · window functions
- Their people's peopleSQL · recursion · grouping
- Use it or lose itSQL · recursion · strings