CodeArena

Compete. Code. Conquer.

Solve coding challenges head-to-head against an AI opponent. Race the clock. Climb the leaderboard.

Difficulty Tier
2436 challenges— Page 1 of 82
CatLang

Reverse a String

Lv.1

Write a function that takes a string and returns it reversed. Examples: reverseStr("hello") => "olleh" reverseStr("world") => "dlrow" Constraints: - 0 <= s.length <= 10000

StringsBeginner
5 test casesNot solved

Count Vowels

Lv.1

Return the number of vowels (a, e, i, o, u) in a string. Case-insensitive. Examples: countVowels("hello") => 2 countVowels("AEIOU") => 5 Constraints: - 0 <= s.length <= 10000

StringsBeginner
5 test casesNot solved

Capitalize First Letter

Lv.1

Write a function that capitalizes the first letter of a string and lowercases the rest. Examples: capitalizeFirst("hello") => "Hello" capitalizeFirst("WORLD") => "World" Constraints: - 0 <= s.length <= 10000

StringsBeginner
5 test casesNot solved

Is Palindrome

Lv.1

Check if a string is a palindrome (reads the same forwards and backwards). Consider only alphanumeric characters and ignore case. Examples: isPalindrome("racecar") => true isPalindrome("hello") => false Constraints: - 0 <= s.length <= 10000

StringsBeginner
5 test casesNot solved

Implement a Stack

Lv.1

Implement a stack data structure with push, pop, peek, and isEmpty methods. push(val) adds to top, pop() removes and returns top (return null if empty), peek() returns top without removing (return null if empty), isEmpty() returns boolean.

Stacks & QueuesBeginner
4 test casesNot solved

Implement a Queue

Lv.1

Implement a queue with enqueue, dequeue, front, and isEmpty methods. enqueue(val) adds to back, dequeue() removes and returns front (null if empty), front() returns front without removing (null if empty), isEmpty() returns boolean.

Stacks & QueuesBeginner
4 test casesNot solved

Crawler Log Folder

Lv.1

You start at the main folder. Given an array of operations: '../' moves to parent (stays if at main), './' stays in current, 'x/' moves to child folder named x. Return the minimum number of operations to go back to the main folder.

Stacks & QueuesBeginner
4 test casesNot solved

Two Sum (Hash Map)

Lv.1

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. Use a hash map for O(n) time. Each input has exactly one solution, and you may not use the same element twice.

Hash MapsBeginner
4 test casesNot solved

Contains Duplicate

Lv.1

Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Use a hash set for optimal performance.

Hash MapsBeginner
5 test casesNot solved

Single Number Using Set

Lv.1

Given a non-empty array of integers nums, every element appears twice except for one. Find that single one using a hash set.

Hash MapsBeginner
4 test casesNot solved

Intersection of Two Arrays

Lv.1

Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must be unique. Result can be in any order.

Hash MapsBeginner
4 test casesNot solved

Factorial (Recursive)

Lv.1

Write a recursive function that computes the factorial of a non-negative integer n. n! = n * (n-1) * ... * 1, and 0! = 1.

RecursionBeginner
5 test casesNot solved

Sum of Digits (Recursive)

Lv.1

Write a recursive function that returns the sum of the digits of a non-negative integer.

RecursionBeginner
5 test casesNot solved

Count Digits (Recursive)

Lv.1

Write a recursive function that counts the number of digits in a non-negative integer.

RecursionBeginner
5 test casesNot solved

Sum of Array (Recursive)

Lv.1

Write a recursive function that returns the sum of all elements in an array. Do not use loops.

RecursionBeginner
5 test casesNot solved

Assign Cookies

Lv.1

You are a parent and want to give cookies to children. Each child i has a greed factor g[i], and each cookie j has a size s[j]. A child is content if s[j] >= g[i]. Maximize the number of content children. Each child gets at most one cookie.

GreedyBeginner
5 test casesNot solved

Maximum Units on a Truck

Lv.1

You are given boxTypes where boxTypes[i] = [numberOfBoxes_i, numberOfUnitsPerBox_i] and truckSize (max number of boxes). Choose boxes to maximize total units on the truck.

GreedyBeginner
4 test casesNot solved

Best Time to Buy and Sell Stock II

Lv.1

Given an array prices where prices[i] is the price of a stock on day i, find the maximum profit. You may buy and sell multiple times (buy before you sell again). You can only hold one share at a time.

GreedyBeginner
4 test casesNot solved

Lemonade Change

Lv.1

At a lemonade stand, each lemonade costs $5. Customers pay with $5, $10, or $20. You must provide correct change. You start with no money. Return true if you can provide change for every customer.

GreedyBeginner
5 test casesNot solved

Generate Parentheses (n=2)

Lv.1

Given n = 2, generate all combinations of well-formed parentheses. Return the result sorted lexicographically.

BacktrackingBeginner
4 test casesNot solved

Subsets

Lv.1

Given an integer array of unique elements, return all possible subsets (the power set). The solution must not contain duplicate subsets. Return subsets sorted by length, then lexicographically.

BacktrackingBeginner
4 test casesNot solved

Permutations

Lv.1

Given an array of distinct integers, return all possible permutations in any order.

BacktrackingBeginner
4 test casesNot solved

Generate Binary Strings

Lv.1

Given an integer n, generate all binary strings of length n. Return them sorted lexicographically.

BacktrackingBeginner
4 test casesNot solved

Power Set Size

Lv.1

Given n, return the total number of subsets of a set with n elements. While the answer is 2^n, implement it by actually generating all subsets via backtracking and counting them.

BacktrackingBeginner
5 test casesNot solved

Check Even or Odd

Lv.1

Given an integer n, return true if n is even and false if n is odd. Use bitwise operations instead of the modulo operator.

Bit ManipulationBeginner
5 test casesNot solved

Get Bit at Position

Lv.1

Given an integer n and a position p (0-indexed from the right), return the bit value (0 or 1) at that position.

Bit ManipulationBeginner
5 test casesNot solved

Set Bit at Position

Lv.1

Given an integer n and a position p (0-indexed from the right), set the bit at that position to 1 and return the result.

Bit ManipulationBeginner
4 test casesNot solved

Clear Bit at Position

Lv.1

Given an integer n and a position p (0-indexed from the right), clear (set to 0) the bit at that position and return the result.

Bit ManipulationBeginner
4 test casesNot solved

Transpose Matrix

Lv.1

Level 1-beginner. Given an m x n matrix, return its transpose. The transpose of a matrix flips it over its main diagonal, switching rows and columns.

MatrixBeginner
4 test casesNot solved

Matrix Diagonal Sum

Lv.1

Level 1-beginner. Given a square matrix, return the sum of both diagonals. If a cell is on both diagonals (center of odd-sized matrix), count it only once.

MatrixBeginner
4 test casesNot solved
...