Coding Challenges

Sharpen your coding skills with real-world challenges. Earn points, climb the leaderboard, and become a top coder.

18

Total Challenges

990

Total Points Available

0+

Active Competitors

Difficulty
Category

Showing 18 challenges

Medium 100 pts

Find All Pairs of Elements in Array

Write a function to find all pairs of elements in an array such that their sum equals a target value. The function should return all pairs in a 2D array, where each pair is sorted in ascending order. If no such pair exists, return an empty array. For example, if the input array is [1, 2, 3, 4, 5] and the target value is 7, the function should return [[2, 5], [3, 4]] because 2 + 5 = 7 and 3 + 4 = 7.

Medium 100 pts

Smallest Window Subarray

Given an array of integers, find the smallest window that contains all elements in the array. The window is defined by its start and end indices. If there are multiple windows that contain all elements, return the one with the smallest end index. If no such window exists, return null. For example, if the input array is [1, 2, 3, 4, 5, 6] and the given array is [1, 4, 5], the smallest window is [4, 5]. Constraints: - The input array has a length between 1 and 1000. - The given array has a length between 1 and 10. - All elements in the input array are between 1 and 1000. - All elements in the given array are distinct and between 1 and 1000. Example: Input: [1, 2, 3, 4, 5, 6], [1, 4, 5] Output: [4, 5]

Medium 100 pts

Find Maximum Sum of Subarray

Write a function that finds the maximum sum of a subarray of a given array of integers. The function should return the maximum sum of a subarray. For example, given the array [-2, -3, 4, -1, -2, 1, 5, -3], the function should return 7, which is the maximum sum of the subarray [4, -1, -2, 1, 5].

Medium 100 pts

Missing Element in Array

Given an array of integers, determine the missing element in the sequence from 1 to n where n is the length of the array. If the array is not in ascending order or does not contain all integers from 1 to n, return -1. If the array contains all integers from 1 to n, return the length of the array. Example: Input: [4, 2, 3], Expected Output: 1.

Medium 100 pts

Rotate Array Elements

Write a function that takes an array of integers as input and rotates it clockwise by one position. For example, if the input array is [1, 2, 3, 4, 5], the function should return [5, 1, 2, 3, 4]. The array can be of any size and may contain duplicate elements. You can assume that the input array is not empty. Provide examples of how your function works with different input arrays.

Medium 100 pts

Flatten a 2D Array

Given a 2D array of integers, write a function to flatten it into a single array. The function should not modify the original array. Examples: Input: [[1, 2], [3, 4], [5, 6]] Output: [1, 2, 3, 4, 5, 6] Constraints: The input array may be empty, and the sub-arrays may also be empty. The input will always be a 2D array.

Medium 25 pts

Maximum Subarray

Given an integer array, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. This is the classic Kadane's Algorithm problem.

Medium 25 pts

2nd Binary Search Implementation

Implement a binary search algorithm that takes a sorted array and a target value, and returns the index of the target if found, or -1 if not found.

Easy 15 pts

Merge Two Sorted Lists

Merge two sorted linked lists and return the merged list as a new sorted list. The new list should be made by splicing together the nodes of the first two lists.

Medium 25 pts

Binary Search Implementation

Implement a binary search algorithm that takes a sorted array and a target value, and returns the index of the target if found, or -1 if not found.

Medium 30 pts

Binary Tree Level Order Traversal

Given the root of a binary tree, return the level order traversal of its nodes' values (i.e., from left to right, level by level) as an array of arrays.

Medium 35 pts

Word Search

Given an m x n grid of characters and a string word, return true if the word exists in the grid. The word can be constructed from sequentially adjacent cells (horizontally or vertically), and each cell may only be used once.

Medium 35 pts

Coin Change

Given an array of coin denominations and a total amount, return the fewest number of coins needed to make up that amount. Return -1 if it cannot be done.

Hard 70 pts

Regular Expression Matching

Given a string s and a pattern p, implement regular expression matching with support for '.' and '*' where '.' matches any single character and '*' matches zero or more of the preceding element.

Easy 10 pts

Reverse a String

Given a string, return the string reversed.

Medium 50 pts

Longest Palindromic Substring

Given a string, return the longest substring that is a palindrome.

Hard 60 pts

Merge K Sorted Lists

You are given an array of k sorted linked lists. Merge them into one sorted linked list and return it.

Easy 10 pts

Two Sum Problem

Given an array of integers and a target sum, return the indices of the two numbers such that they add up to the target.