Dev Duel

Sharpen your skills with real coding challenges

Practice JavaScript, Python, SQL, and C++ with guided challenges built for beginners through advanced learners.

Daily Duel

Calculate Total Sales Per Employee Using SQL GROUP BY

Learn how to aggregate sales data by employee using the SQL GROUP BY clause and aggregate functions in this beginner-friendly challenge.

Start Today’s Duel
beginner10 minutes

Browse by language

Choose a language and jump into practical challenges.

Featured Duels

Start with strong practice problems across languages.

beginner5 minutes

Sum Two Values

Write a function that returns the sum of two numbers.

functionsparametersreturn values
beginner7 minutes

Count Even Numbers

Count how many even numbers appear in a list.

loopsconditionalslists
intermediate10 minutes

Find the Second Highest Salary

Return the second highest salary from an employees table.

subqueriessortingdistinct
intermediate12 minutes

Reverse a String Without Built-Ins

Reverse a string manually without using built-in reverse helpers.

stringsloopsindexing
beginner10 minutes

Calculate Total Sales Per Employee Using SQL GROUP BY

Learn how to aggregate sales data by employee using the SQL GROUP BY clause and aggregate functions in this beginner-friendly challenge.

GROUP BYSUM()ORDER BY
beginner10 minutes

Beginner Challenge: Create a Function to Capitalize the First Letter of Each Word

Practice string manipulation by writing a JavaScript function that capitalizes the first letter of every word in a given sentence.

string manipulationfunctionsarrays
beginner10 minutes

Sum All Odd Numbers in a List

Write a function that calculates the sum of all odd numbers in a given list of integers.

loopsconditional statementsfunctions
beginner10 minutes

SQL Beginner Challenge: Calculate Total Sales per Customer

Practice basic SQL aggregation by calculating the total sales amount for each customer in a sales database.

SQL AggregationGROUP BY clauseBasic SQL functions
beginner10 minutes

Simple To-Do List App in JavaScript

Create a basic to-do list application where users can add tasks, mark them as completed, and see the updated list.

arraysobjectsfunctions
beginner10 minutes

Fix the Broken SELECT Query to Retrieve Employee Names

A simple SQL query intended to retrieve all employee names is not working correctly. Your task is to identify and fix the syntax errors so the query runs successfully and returns the correct results.

Basic SQL syntaxSELECT statementColumn and table naming
advanced15 minutes

Build a SQL Function to Calculate Running Median Over a Dynamic Window

In this challenge, you will create a SQL function that calculates the running median value of a numeric column over a dynamic sliding window based on timestamps. This requires advanced use of window functions, array manipulation, and median calculation within SQL.

Window FunctionsMedian CalculationAggregate Functions
intermediate15 minutes

Design and Query a Library Management Data Model

Create a SQL data model for a library management system and write queries to retrieve meaningful information about books, authors, borrowers, and loans.

SQL JOINsmany-to-many relationshipsforeign keys
advanced10 minutes

Predict Output of Complex Recursive and Bitwise Operations in C++

Analyze a complex C++ program that uses recursion combined with bitwise operations and tricky short-circuit logic. Predict the exact output produced by the program without running it.

recursionbitwise operationsstatic variables
advanced15 minutes

Build a Decorator to Cache Function Results with Expiry

Create a Python decorator function that caches the results of an expensive function call, with support for automatic expiration of cached values after a given time-to-live (TTL).

decoratorscachingfunction arguments
intermediate15 minutes

Build a Todo List Manager with Filtering and Prioritization

Create a JavaScript function that manages a list of todo items, allowing for adding, removing, updating status, and filtering tasks based on their priority and completion status.

closuresarraysobjects
advanced15 minutes

Fix Bug in Async Data Aggregation and Error Handling Function

Debug and fix a complex asynchronous JavaScript function designed to fetch and aggregate data from multiple APIs with error handling. The current implementation contains subtle bugs causing unhandled promise rejections and incorrect data aggregation.

asynchronous programmingerror handlingpromises
beginner10 minutes

Fix the Bug in a C++ Function to Calculate Factorial

Identify and fix the bug in a simple C++ function intended to calculate the factorial of a given number. The function currently produces incorrect output for some inputs.

variables initializationfor loopbasic arithmetic operations
advanced15 minutes

Build an Advanced Debounce Function with Immediate and Cancel Options

Create a robust debounce utility function in JavaScript that delays invoking a function until after a specified wait time elapses since the last call. Support both immediate execution on the leading edge and the ability to cancel a pending invocation.

closuresasynchronous timingfunction properties
intermediate10 minutes

Refactor SQL Query for Sales Aggregation Optimization

Improve the given SQL query that calculates total and average sales per product category. The original query uses multiple subqueries and redundant joins, causing inefficiencies. Refactor it to be cleaner and more performant while preserving the exact results.

SQL joinsaggregate functionsquery optimization
intermediate30 minutes

Build a Movie Recommendation Engine Based on User Ratings

Create a Python mini-project that recommends movies to a user based on their past ratings and similarity to other users' ratings. Implement basic collaborative filtering logic without external libraries.

collaborative filteringmatrix operationssimilarity metrics
beginner10 minutes

Simple Contact List Manager in C++

Create a basic contact list manager where users can add, display, and search contacts using console input and output.

structsvectorsloops
advanced15 minutes

Refactor Complex C++ Class for Improved Readability and Maintainability

Given a complex and messy C++ class implementation, refactor the code to improve readability, maintainability, and follow best OOP practices without changing the program's behavior.

Code RefactoringC++ Best PracticesObject-Oriented Programming
beginner10 minutes

Build a Simple To-Do List App

Create a basic to-do list application in JavaScript where users can add, view, and remove tasks. This project helps beginners practice working with arrays, functions, and DOM manipulation.

ArraysFunctionsArray methods
intermediate10 minutes

Predict the Output of an SQL Query with Subqueries and Joins

Analyze the given SQL query involving JOINs and a correlated subquery, and predict the final output based on a provided sample database schema and data.

Correlated subqueriesJOIN operationsAggregation functions
advanced40 minutes

Design and Implement a Scalable E-Commerce Order Tracking Data Model

Build a comprehensive SQL data model supporting order tracking, including customers, products, orders, shipments, and status history, ensuring efficient querying for complex business insights.

SQL schema designData normalizationRelational modeling
intermediate10 minutes

Create a SQL Function to Calculate Running Sales Total per Customer

Build a SQL function that calculates the running total of sales for each customer ordered by the sale date.

window functionsrunning totalSQL function
advanced15 minutes

Refactor and Optimize Complex Data Processing Function

Given a large-function script that processes a nested data structure with redundant loops and poor readability, refactor the code to improve maintainability, reduce complexity, and optimize performance without changing its output.

code refactoringperformance optimizationcode readability
beginner10 minutes

Build a Function to Calculate the Area of a Rectangle

Write a simple C++ function that calculates the area of a rectangle given its width and height.

functionsreturn statement
intermediate10 minutes

Predict the Output of Nested Array and Object Destructuring with Defaults

Analyze the given JavaScript code involving nested array and object destructuring with default values and predict the final output.

JavaScript destructuringdefault values in destructuringarrays and objects
beginner10 minutes

Fix the Bug in a Simple Temperature Converter

Debug a basic C++ function that is supposed to convert temperatures from Celsius to Fahrenheit but currently produces incorrect results.

arithmetic operationsoperator precedencedata types and integer division
advanced15 minutes

Fix the Aggregation Bug in Employee Salary Report Query

An SQL query intended to generate a report summarizing total salaries by department and job title has incorrect aggregation logic causing wrong results. Your task is to identify and fix the bugs in the query to produce accurate aggregation.

SQL aggregationGROUP BY clauseJOIN operations
intermediate10 minutes

Build a Function to Flatten a Nested List of Integers

Create a Python function that takes a nested list of integers and returns a flat list containing all the integers in their original order.

recursionlist manipulation
advanced15 minutes

Build a Function to Serialize and Deserialize Nested Dictionaries with Custom Rules

Create a Python function to serialize a nested dictionary into a custom string format and another function to revert it back, handling complex nesting and type conversions.

recursionstring parsingdata serialization
intermediate10 minutes

Refactor and Improve Readability of a Data Filtering Function

Refactor a given Python function that filters and processes a list of dictionaries to improve its code quality, readability, and maintainability without altering its output behavior.

code refactoringlist comprehensionsconditional filtering
beginner10 minutes

Predict the Output of a Simple Number Check Function

Analyze a Python function that checks if a number is positive, negative, or zero, and predict its output for given inputs.

conditionalsfunctions
intermediate10 minutes

Refactor a Function to Cleanly Aggregate User Purchases

The provided JavaScript function processes an array of user purchase objects to calculate total spending per user. The existing code works but is messy and repetitive. Refactor it for clarity, reusability, and improved readability without changing its behavior.

JavaScript arraysObject manipulationArray reduce method
advanced15 minutes

Refactor and Optimize Complex Sales Reporting SQL Query

Optimize a poorly written, inefficient SQL query that aggregates sales data by region and product category while filtering on multiple conditions. Improve readability, performance and ensure the output remains correct.

SQL optimizationJoins and subqueriesAggregation and grouping
intermediate20 minutes

Build a Simple Inventory Management System in C++

Create a console-based inventory management mini-project using C++. Implement features to add, update, delete, and display items stored in an inventory using vectors and classes.

classes and objectsstd::vectorloops and conditionals
advanced15 minutes

Implement a Memoized Recursive Function to Compute the nth Catalan Number

Create an efficient C++ function that calculates the nth Catalan number using recursion with memoization. Catalan numbers appear in various combinatorial problems and grow quickly, so naive recursion is inefficient for larger inputs.

recursionmemoizationdynamic programming
beginner10 minutes

Basic Calculator CLI Mini-Project in C++

Create a simple command-line calculator program in C++ that performs basic arithmetic operations like addition, subtraction, multiplication, and division based on user input.

variablesconditional statementsinput/output
intermediate15 minutes

Build a Personal Expense Tracker Mini Project

Create a Python program that allows users to add, view, and analyze their personal expenses over time, helping them track spending habits.

lists and dictionariesloop and conditionalsdata aggregation
beginner10 minutes

Create a Function to Calculate the Square of a Number

Write a Python function that takes a single number as input and returns its square. This is a fundamental exercise to practice defining functions and using arithmetic operators.

functionsarithmetic operatorsreturn statement
advanced15 minutes

Fix a Bug in an SQL Query for Aggregated Sales Performance with Window Functions

Identify and fix the bug in a complex SQL query that attempts to calculate monthly sales performance rankings by salesperson, using window functions and joins.

window functionsSQL aggregationjoins
beginner10 minutes

Refactor SQL Query to Optimize Simple SELECT with CASE

Improve the readability and efficiency of a beginner-level SQL query that uses multiple CASE statements to classify product sales data without changing its behavior.

CASE statementsSQL query refactoringquery readability
beginner10 minutes

Fix the SQL Query to Retrieve Employees with Salary Over 50000

In this challenge, you are given a broken SQL query intended to select all employees earning more than 50000. Your task is to identify and fix the bugs so that the query returns the correct results.

SQL SELECT statementWHERE clauseComparison operators
intermediate10 minutes

Refactor a Function to Compute Unique Elements Frequency

Improve the provided Python function that calculates the frequency of unique elements in a list. Refactor the code for better readability, efficiency, and Pythonic style without changing its behavior.

dictionarycollections.Countercode refactoring
intermediate10 minutes

Predict the Output of a Complex Nested Loop with Conditional Logic in C++

Analyze the given C++ code that uses nested loops with conditional statements to manipulate variables. Predict the output without running the code.

nested loopsconditional statementsvariable manipulation
intermediate10 minutes

C++ Student Grade Management System

Build a mini-project that manages student grades by storing names and scores, calculating averages, and allowing queries for top students.

Classes and StructsVectorsBasic Algorithms (averaging, max finding)
advanced60 minutes

Design and Optimize a Sales Database Schema with Advanced Queries

Create a normalized database schema for a retail sales system that handles customers, products, orders, and shipments. Then, write optimized SQL queries to retrieve key business insights including sales trends, customer segmentation, and shipment statuses.

Normalized schema designRelational database modelingSQL aggregation and window functions
intermediate10 minutes

Refactor a Function to Calculate Average Scores with Better Readability and Efficiency

Improve a messy JavaScript function that calculates average scores from an array of student objects, making the code cleaner, more efficient, and easier to understand without changing its behavior.

code refactoringarray methodscode readability
advanced45 minutes

Design and Query a Multi-Level Employee Management Hierarchy

Create a relational data model to represent an organization's employee hierarchy with multiple reporting levels and implement complex SQL queries to retrieve hierarchical reports and aggregate statistics.

recursive Common Table Expressionsself-referencing foreign keyshierarchical data modeling
advanced30 minutes

Design and Query an Employee Hierarchy Data Model

Create a normalized data model to represent an employee hierarchy within a company, then write an advanced SQL query to retrieve hierarchical reports and aggregated information.

recursive CTEself-referencing foreign keydata normalization
advanced20 minutes

Advanced C++ Code Refactor: Optimize and Modernize Complex Class Implementation

Given a legacy C++ class with complex logic, repetitive code, and poor maintainability, your task is to refactor it for readability, efficiency, and modern C++ best practices without altering its external behavior.

Modern C++Smart pointersSTL algorithms
advanced15 minutes

Refactor Complex Nested Callbacks into Clean Async/Await Flow

Refactor a nested callback-based event processing function into clean, modular, and maintainable async/await style JavaScript code without changing the behavior or output.

async/awaitcallbackspromises
advanced15 minutes

Create a SQL Function to Calculate Customer Lifetime Value (CLV)

Write a SQL function that calculates the Customer Lifetime Value (CLV) based on customer transactions, applying discounting over time and accounting for customer churn rate.

window functionsdate/time calculationdiscounted cash flow
intermediate10 minutes

Fix the Bug in Array Filtering and Object Mapping Function

Identify and fix the bug in a JavaScript function designed to filter an array of user objects and map them to a list of their names based on age criteria.

array filteringarray mappingcallback functions
intermediate15 minutes

Build a Task Manager CLI Application in Python

Create a command-line task manager in Python that allows users to add, complete, delete, and list tasks with due dates and priorities.

datetime handlinglist sortingdictionary usage
beginner10 minutes

Simple Budget Tracker

Create a basic C++ program that helps track expenses and calculate the remaining budget. Users will input their total budget and then enter expenses one by one. The program will output the remaining budget after each expense and a summary at the end.

variablesloopsconditionals
intermediate15 minutes

Create a Deep Object Merge Function

Build a JavaScript function that takes two objects and merges them deeply, combining nested objects instead of overwriting them.

recursionobject manipulationimmutability
intermediate10 minutes

Refactor SQL Query for Optimized Employee Sales Report

Improve the given SQL query for generating a monthly sales report by employee to increase readability and performance without changing the output.

SQL joinsAggregate functionsQuery optimization
advanced10 minutes

Predict the Output of Complex Pointer and Reference Manipulations in C++

Analyze the given C++ code involving multiple levels of pointers, references, and pre/post-increment operators. Predict the exact output after all manipulations, demonstrating deep understanding of pointer arithmetic, reference binding, and operator precedence.

pointer arithmeticreference to pointerpre-increment vs post-increment
advanced15 minutes

Fix the Recursive Sales Totals Query for Hierarchical Employees

You are given a broken SQL query intended to calculate total sales made by each employee and their subordinates in a hierarchical company structure. The query uses a recursive CTE but produces incorrect or incomplete totals. Your task is to identify and fix the bugs so that the query accurately computes cumulative sales totals including all levels of subordinates.

recursive CTEhierarchical queriesaggregation
beginner10 minutes

Create a Function to Convert Celsius to Fahrenheit

Write a JavaScript function that converts a temperature from Celsius to Fahrenheit.

functionsarithmetic operatorsreturn statement
intermediate15 minutes

Design and Query an Employee-Project Assignment Schema

Create a normalized database schema to manage employees, projects, and their assignments. Write SQL queries to retrieve project involvement and employee workloads.

database normalizationjoins (LEFT JOIN)aggregate functions (SUM, COUNT)
advanced20 minutes

Refactor Complex C++ Banking System for Maintainability and Performance

Refactor the provided C++ code of a banking system that handles multiple account types, transactions, and interest calculations. The goal is to improve code quality, maintainability, and performance without changing the system's behavior.

inheritancepolymorphismcode refactoring
beginner10 minutes

Predict the Output of a Basic For Loop with Condition

Analyze the given JavaScript code snippet involving a for loop and conditional statements, then determine the output printed to the console.

for loopconditionalsstring concatenation
advanced15 minutes

Fix Memory Leak and Logic Bug in Custom Linked List Implementation

Identify and fix the memory management and logic bugs in a custom singly linked list class implemented in C++. The list supports insertion and search operations but has subtle issues causing memory leaks and incorrect behavior.

Memory managementPointers and dynamic allocationLinked list traversal
beginner10 minutes

Refactor Messy Code to Calculate the Sum of Even Numbers

Improve the readability and quality of a Python function that calculates the sum of even numbers from a list, while keeping the output correct.

loopsconditionalsfunctions
intermediate10 minutes

Fix the Logic Bug in the Array Frequency Counter

The given C++ function is intended to count the frequency of each integer in an input vector and return the result as a map. However, the current implementation produces incorrect frequency counts due to a logic bug. Your task is to identify and fix the bug so that the function returns accurate counts.

map usageloopsconditional logic
beginner10 minutes

Create a Simple Employee and Department Tables with Basic Queries

Build and query basic employee and department tables to practice simple SQL data modeling and retrieval.

CREATE TABLEINSERT INTOINNER JOIN