Dev Duel

C++ Challenges

Work on variables, loops, functions, OOP, and problem-solving.

Filter challenges

Narrow down by difficulty or category.

Showing 40 of 40 challenges

All challenges

Practice concepts, improve problem-solving, and build confidence.

intermediate12 minutes

Reverse a String Without Built-Ins

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

stringsstringsloops
beginner10 minutes

Calculate the Factorial of a Number in C++

Learn how to write a function that calculates the factorial of a given non-negative integer using C++.

functionsfunctionsloops
intermediate10 minutes

Refactor Messy Inventory Management Code

Improve the structure and readability of a cluttered C++ function that manages inventory updates while preserving its original behavior.

code-qualitycode refactoringstd::map
beginner10 minutes

Predict the Output of a Simple Loop and Conditional in C++

Analyze the given C++ code involving a loop and conditional statements, and predict the exact output it produces when run.

logicloopsconditionals
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.

logicrecursionbitwise operations
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.

debuggingvariables initializationfor loop
advanced20 minutes

Implement a Thread-Safe Memoization Function in C++

Build a reusable templated function that memoizes results of expensive computations in a thread-safe manner using modern C++ features.

functionstemplatesthread safety
beginner10 minutes

Fix the Bug in Counting Even Numbers in an Array

Identify and fix the bug in the given C++ function that is supposed to count the number of even numbers in an integer array.

debuggingloopsarrays
intermediate10 minutes

Build a Function to Rotate Elements in an Array

Write a C++ function that rotates the elements of an array to the right by a given number of steps. The rotation should handle cases where the number of steps is larger than the array size.

functionsarraysin-place modification
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.

mini-projectsstructsvectors
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-qualityCode RefactoringC++ Best Practices
advanced15 minutes

Implement a Custom Memoized Recursive Function for Large Fibonacci Numbers

Write an optimized C++ function to compute Fibonacci numbers using memoization. The function must efficiently handle very large inputs by caching intermediate results to avoid exponential time complexity, showcasing mastery of recursion, dynamic programming, and function optimization.

functionsrecursionmemoization
beginner10 minutes

Refactor Messy Loop and Conditionals in C++

Improve the readability and maintainability of a C++ function that calculates the sum of even numbers in a vector. Keep its behavior exactly the same while cleaning up the code.

code-qualityloopsconditionals
intermediate10 minutes

Build a Function to Merge and Sort Two Arrays

Write a C++ function that takes two integer arrays as inputs, merges them into a single array, removes duplicates, and returns the sorted result.

functionsvectorssorting
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.

functionsfunctionsreturn statement
intermediate10 minutes

Build a Function to Rotate a Vector by k Positions

Write a C++ function that takes a vector of integers and an integer k, and returns the vector rotated to the right by k positions. This exercise tests your understanding of vector manipulation, modular arithmetic, and function implementation.

functionsvectorsmodular arithmetic
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.

debuggingarithmetic operationsoperator precedence
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.

mini-projectsclasses and objectsstd::vector
beginner10 minutes

Simple Task Tracker Mini-Project in C++

Build a basic console-based task tracker app in C++ that allows users to add, view, and remove tasks. Practice working with vectors, loops, and conditionals while creating a helpful daily tool.

mini-projectsvectorsloops
intermediate15 minutes

Build a Function to Compute Running Median from a Stream of Integers

Write a C++ function that accepts a vector of integers representing a stream of numbers and returns a vector containing the running median after each new number is added.

functionsheapspriority_queue
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.

functionsrecursionmemoization
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.

mini-projectsvariablesconditional statements
advanced90 minutes

Advanced Multithreaded File Processing and Data Aggregation in C++

Create a performant C++ application that reads multiple large text files concurrently, processes the extracted data to compute aggregate statistics, and outputs a sorted summary report.

mini-projectsMultithreadingFile I/O
advanced120 minutes

Advanced Portfolio Management System in C++

Create a mini-project to design and implement a portfolio management system that tracks multiple investment assets, calculates real-time portfolio value, and supports transaction history and performance analysis.

mini-projectsclasses and objectsdata structures (maps, vectors)
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.

logicnested loopsconditional statements
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.

mini-projectsClasses and StructsVectors
advanced15 minutes

Refactor a Complex C++ Matrix Multiplication with Thread Safety and Performance in Mind

Improve a messy and inefficient C++ matrix multiplication code by refactoring it to enhance readability, performance, and thread safety while preserving its original functionality.

code-qualityC++ refactoringperformance optimization
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.

code-qualityModern C++Smart pointers
beginner10 minutes

Refactor a Simple Grade Calculator for Clarity

Improve the readability and structure of a basic C++ grade calculation function without changing its behavior.

code-qualityconditional statementscode readability
intermediate10 minutes

Predict the Output: Multi-dimensional Array and Pointer Arithmetic in C++

Analyze the provided C++ code snippet involving multi-dimensional arrays and pointer arithmetic. Predict the output without running the code.

logicpointer arithmeticmulti-dimensional arrays
beginner10 minutes

Build a Simple To-Do List Application in C++

Create a beginner-friendly console-based to-do list app where users can add, view, and remove tasks.

mini-projectsvectorsloops
advanced90 minutes

Advanced C++ Mini-Project: Multi-Threaded Task Scheduler with Prioritization

Build an advanced multi-threaded task scheduler in C++ that accepts tasks with different priorities, efficiently manages a thread pool, and executes tasks in priority order. The scheduler should support adding, cancelling, and monitoring tasks in real-time.

mini-projectsmultithreadingthread synchronization
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.

mini-projectsvariablesloops
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.

logicpointer arithmeticreference to pointer
advanced15 minutes

Build a Function to Perform Multi-level Memoized Matrix Chain Multiplication

Implement an optimized function to compute the minimum number of scalar multiplications needed to multiply a given chain of matrices using memoization to achieve efficient performance.

functionsdynamic programmingmemoization
intermediate10 minutes

Build a Function to Calculate the Running Median of an Integer Stream

Write a function in C++ that processes a stream of integers and returns the median after each new number is added. The function should efficiently handle the insertion and calculation steps to provide medians dynamically.

functionsheapspriority_queue
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.

code-qualityinheritancepolymorphism
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.

debuggingMemory managementPointers and dynamic allocation
intermediate15 minutes

Employee Performance Tracker

Build a C++ program to manage and analyze employee performance data by storing, updating, and calculating key statistics from the data.

mini-projectsstructsvectors
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.

debuggingmap usageloops