slug
stringlengths
3
79
solution_id
stringlengths
13
89
primary_algorithm
stringclasses
22 values
verified
null
messages
listlengths
3
3
global-and-local-inversions
global-and-local-inversions__02__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums of length n which represents a permuta...
split-bst
split-bst__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary search tree (BST) and an integer target, split ...
swap-adjacent-in-lr-string
swap-adjacent-in-lr-string__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nIn a string composed of 'L', 'R', and 'X' characters, like \"RXXLRXRXL\", ...
swim-in-rising-water
swim-in-rising-water__01__java
Binary Search
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an n x n integer matrix grid where each value grid[i][j] rep...
k-th-symbol-in-grammar
k-th-symbol-in-grammar__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nWe build a table of n rows (1-indexed). We start by writing 0 in the 1st r...
k-th-symbol-in-grammar
k-th-symbol-in-grammar__02__java
Bit Manipulation
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nWe build a table of n rows (1-indexed). We start by writing 0 in the 1st r...
reaching-points
reaching-points__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven four integers sx, sy, tx, and ty, return true if it is possible to c...
rabbits-in-forest
rabbits-in-forest__01__java
Greedy
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is a forest with an unknown number of rabbits. We asked n rabbits \"...
transform-to-chessboard
transform-to-chessboard__01__java
Bit Manipulation
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an n x n binary grid board. In each move, you can swap any t...
minimum-distance-between-bst-nodes
minimum-distance-between-bst-nodes__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a Binary Search Tree (BST), return the minimum differenc...
letter-case-permutation
letter-case-permutation__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s, you can transform every letter individually to be lowerc...
letter-case-permutation
letter-case-permutation__02__java
Backtracking
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s, you can transform every letter individually to be lowerc...
is-graph-bipartite
is-graph-bipartite__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is an undirected graph with n nodes, where each node is numbered bet...
is-graph-bipartite
is-graph-bipartite__02__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is an undirected graph with n nodes, where each node is numbered bet...
k-th-smallest-prime-fraction
k-th-smallest-prime-fraction__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a sorted integer array arr containing 1 and prime numbers, w...
cheapest-flights-within-k-stops
cheapest-flights-within-k-stops__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n cities connected by some number of flights. You are given an a...
cheapest-flights-within-k-stops
cheapest-flights-within-k-stops__02__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n cities connected by some number of flights. You are given an a...
rotated-digits
rotated-digits__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nAn integer x is a good if after rotating each digit individually by 180 de...
rotated-digits
rotated-digits__02__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nAn integer x is a good if after rotating each digit individually by 180 de...
escape-the-ghosts
escape-the-ghosts__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are playing a simplified PAC-MAN game on an infinite 2-D grid. You sta...
domino-and-tromino-tiling
domino-and-tromino-tiling__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou have two types of tiles: a 2 x 1 domino shape and a tromino shape. You...
custom-sort-string
custom-sort-string__01__java
Sorting
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two strings order and s. All the characters of order are uni...
custom-sort-string
custom-sort-string__02__java
Sorting
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two strings order and s. All the characters of order are uni...
number-of-matching-subsequences
number-of-matching-subsequences__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s and an array of strings words, return the number of words...
number-of-matching-subsequences
number-of-matching-subsequences__02__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s and an array of strings words, return the number of words...
number-of-matching-subsequences
number-of-matching-subsequences__03__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s and an array of strings words, return the number of words...
preimage-size-of-factorial-zeroes-function
preimage-size-of-factorial-zeroes-function__01__java
Binary Search
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nLet f(x) be the number of zeroes at the end of x!. Recall that x! = 1 * 2 ...
valid-tic-tac-toe-state
valid-tic-tac-toe-state__01__java
Array
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a Tic-Tac-Toe board as a string array board, return true if and only...
number-of-subarrays-with-bounded-maximum
number-of-subarrays-with-bounded-maximum__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an integer array nums and two integers left and right, return the nu...
number-of-subarrays-with-bounded-maximum
number-of-subarrays-with-bounded-maximum__02__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an integer array nums and two integers left and right, return the nu...
rotate-string
rotate-string__01__java
String
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven two strings s and goal, return true if and only if s can become goal...
all-paths-from-source-to-target
all-paths-from-source-to-target__01__java
Backtracking
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, f...
all-paths-from-source-to-target
all-paths-from-source-to-target__02__java
Backtracking
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, f...
smallest-rotation-with-highest-score
smallest-rotation-with-highest-score__01__java
Array
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array nums. You can rotate it by a non-negative integer k...
champagne-tower
champagne-tower__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nWe stack glasses in a pyramid, where the first row has 1 glass, the second...
champagne-tower
champagne-tower__02__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nWe stack glasses in a pyramid, where the first row has 1 glass, the second...
similar-rgb-color
similar-rgb-color__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThe red-green-blue color \"#AABBCC\" can be written as \"#ABC\" in shortha...
minimum-swaps-to-make-sequences-increasing
minimum-swaps-to-make-sequences-increasing__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two integer arrays of the same length nums1 and nums2. In on...
find-eventual-safe-states
find-eventual-safe-states__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is a directed graph of n nodes with each node labeled from 0 to n - ...
find-eventual-safe-states
find-eventual-safe-states__02__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is a directed graph of n nodes with each node labeled from 0 to n - ...
bricks-falling-when-hit
bricks-falling-when-hit__01__java
Graph
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an m x n binary grid, where each 1 represents a brick and 0 ...
unique-morse-code-words
unique-morse-code-words__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nInternational Morse Code defines a standard encoding where each letter is ...
split-array-with-same-average
split-array-with-same-average__01__java
Binary Search
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums.\n\nYou should move each element of nu...
number-of-lines-to-write-string
number-of-lines-to-write-string__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a string s of lowercase English letters and an array widths ...
max-increase-to-keep-city-skyline
max-increase-to-keep-city-skyline__01__java
Greedy
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is a city composed of n x n blocks, where each block contains a sing...
soup-servings
soup-servings__01__java
Memoization
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou have two soups, A and B, each starting with n mL. On every turn, one o...
expressive-words
expressive-words__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nSometimes people repeat letters to represent extra feeling. For example:\n...
chalkboard-xor-game
chalkboard-xor-game__01__java
Bit Manipulation
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array of integers nums represents the numbers written on ...
subdomain-visit-count
subdomain-visit-count__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nA website domain \"discuss.leetcode.com\" consists of various subdomains. ...
largest-sum-of-averages
largest-sum-of-averages__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums and an integer k. You can partition th...
largest-sum-of-averages
largest-sum-of-averages__02__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums and an integer k. You can partition th...
binary-tree-pruning
binary-tree-pruning__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, return the same tree where every subtree ...
bus-routes
bus-routes__01__java
BFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array routes representing bus routes where routes[i] is a...
ambiguous-coordinates
ambiguous-coordinates__01__java
Backtracking
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nWe had some 2-dimensional coordinates, like \"(1, 3)\" or \"(2, 0.5)\". Th...
linked-list-components
linked-list-components__01__java
Linked List
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given the head of a linked list containing unique integer values a...
race-car
race-car__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYour car starts at position 0 and speed +1 on an infinite number line. You...
most-common-word
most-common-word__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string paragraph and a string array of the banned words banned, re...
short-encoding-of-words
short-encoding-of-words__01__java
Trie
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nA valid encoding of an array of words is any reference string s and array ...
short-encoding-of-words
short-encoding-of-words__02__java
Trie
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nA valid encoding of an array of words is any reference string s and array ...
shortest-distance-to-a-character
shortest-distance-to-a-character__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s and a character c that occurs in s, return an array of in...
card-flipping-game
card-flipping-game__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two 0-indexed integer arrays fronts and backs of length n, w...
binary-trees-with-factors
binary-trees-with-factors__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an array of unique integers, arr, where each integer arr[i] is stric...
goat-latin
goat-latin__01__java
String
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a string sentence that consist of words separated by spaces....
friends-of-appropriate-ages
friends-of-appropriate-ages__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n persons on a social media website. You are given an integer ar...
most-profit-assigning-work
most-profit-assigning-work__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou have n jobs and m workers. You are given three arrays: difficulty, pro...
most-profit-assigning-work
most-profit-assigning-work__02__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou have n jobs and m workers. You are given three arrays: difficulty, pro...
making-a-large-island
making-a-large-island__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an n x n binary matrix grid. You are allowed to change at mo...
count-unique-characters-of-all-substrings-of-a-given-string
count-unique-characters-of-all-substrings-of-a-given-string__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nLet's define a function countUniqueChars(s) that returns the number of uni...
consecutive-numbers-sum
consecutive-numbers-sum__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an integer n, return the number of ways you can write n as the sum o...
positions-of-large-groups
positions-of-large-groups__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nIn a string s of lowercase letters, these letters form consecutive groups ...
masking-personal-information
masking-personal-information__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a personal information string s, representing either an emai...
flipping-an-image
flipping-an-image__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an n x n binary matrix image, flip the image horizontally, then inve...
find-and-replace-in-string
find-and-replace-in-string__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a 0-indexed string s that you must perform k replacement ope...
sum-of-distances-in-tree
sum-of-distances-in-tree__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is an undirected connected tree with n nodes labeled from 0 to n - 1...
image-overlap
image-overlap__01__java
Array
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two images, img1 and img2, represented as binary, square mat...
rectangle-overlap
rectangle-overlap__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nAn axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where...
new-21-game
new-21-game__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nAlice plays the following game, loosely based on the card game \"21\".\n\n...
new-21-game
new-21-game__02__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nAlice plays the following game, loosely based on the card game \"21\".\n\n...
push-dominoes
push-dominoes__01__java
BFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n dominoes in a line, and we place each domino vertically uprigh...
similar-string-groups
similar-string-groups__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nTwo strings, X and Y, are considered similar if either they are identical ...
magic-squares-in-grid
magic-squares-in-grid__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nA 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 t...
keys-and-rooms
keys-and-rooms__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n rooms labeled from 0 to n - 1 and all the rooms are locked exc...
keys-and-rooms
keys-and-rooms__02__java
BFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n rooms labeled from 0 to n - 1 and all the rooms are locked exc...
split-array-into-fibonacci-sequence
split-array-into-fibonacci-sequence__01__java
Backtracking
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a string of digits num, such as \"123456579\". We can split ...
guess-the-word
guess-the-word__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array of unique strings words where words[i] is six lette...
backspace-string-compare
backspace-string-compare__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven two strings s and t, return true if they are equal when both are typ...
hand-of-straights
hand-of-straights__01__java
Sorting
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nAlice has some number of cards and she wants to rearrange the cards into g...
hand-of-straights
hand-of-straights__02__java
Greedy
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nAlice has some number of cards and she wants to rearrange the cards into g...
shortest-path-visiting-all-nodes
shortest-path-visiting-all-nodes__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou have an undirected, connected graph of n nodes labeled from 0 to n - 1...
shortest-path-visiting-all-nodes
shortest-path-visiting-all-nodes__02__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou have an undirected, connected graph of n nodes labeled from 0 to n - 1...
shifting-letters
shifting-letters__01__java
Array
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a string s of lowercase English letters and an integer array...
maximize-distance-to-closest-person
maximize-distance-to-closest-person__01__java
Array
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array representing a row of seats where seats[i] = 1 repr...
rectangle-area-ii
rectangle-area-ii__01__java
Array
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a 2D array of axis-aligned rectangles. Each rectangle[i] = [...
loud-and-rich
loud-and-rich__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is a group of n people labeled from 0 to n - 1 where each person has...
peak-index-in-a-mountain-array
peak-index-in-a-mountain-array__01__java
Binary Search
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer mountain array arr of length n where the values i...
car-fleet
car-fleet__01__java
Sorting
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n cars at given miles away from the starting mile 0, traveling t...
k-similar-strings
k-similar-strings__01__java
BFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nStrings s1 and s2 are k-similar (for some non-negative integer k) if we ca...
k-similar-strings
k-similar-strings__02__java
BFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nStrings s1 and s2 are k-similar (for some non-negative integer k) if we ca...
exam-room
exam-room__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is an exam room with n seats in a single row labeled from 0 to n - 1...
score-of-parentheses
score-of-parentheses__01__java
String
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a balanced parentheses string s, return the score of the string.\n\n...