slug
stringlengths
3
79
solution_id
stringlengths
13
89
primary_algorithm
stringclasses
22 values
verified
null
messages
listlengths
3
3
find-the-shortest-superstring
find-the-shortest-superstring__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 strings words, return the smallest string that contains ...
delete-columns-to-make-sorted
delete-columns-to-make-sorted__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 of n strings strs, all of the same length.\n\nThe s...
minimum-increment-to-make-array-unique
minimum-increment-to-make-array-unique__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\nYou are given an integer array nums. In one move, you can pick an index i ...
minimum-increment-to-make-array-unique
minimum-increment-to-make-array-unique__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\nYou are given an integer array nums. In one move, you can pick an index i ...
validate-stack-sequences
validate-stack-sequences__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 two integer arrays pushed and popped each with distinct values, retu...
most-stones-removed-with-same-row-or-column
most-stones-removed-with-same-row-or-column__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\nOn a 2D plane, we place n stones at some integer coordinate points. Each c...
most-stones-removed-with-same-row-or-column
most-stones-removed-with-same-row-or-column__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\nOn a 2D plane, we place n stones at some integer coordinate points. Each c...
bag-of-tokens
bag-of-tokens__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\nYou start with an initial power of power, an initial score of 0, and a bag...
largest-time-for-given-digits
largest-time-for-given-digits__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 an array arr of 4 digits, find the latest 24-hour time that can be m...
reveal-cards-in-increasing-order
reveal-cards-in-increasing-order__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 an integer array deck. There is a deck of cards where every ...
flip-equivalent-binary-trees
flip-equivalent-binary-trees__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\nFor a binary tree T, we can define a flip operation as follows: choose any...
largest-component-size-by-common-factor
largest-component-size-by-common-factor__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 integer array of unique positive integers nums. Consider ...
verifying-an-alien-dictionary
verifying-an-alien-dictionary__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\nIn an alien language, surprisingly, they also use English lowercase letter...
array-of-doubled-pairs
array-of-doubled-pairs__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\nGiven an integer array of even length arr, return true if it is possible t...
delete-columns-to-make-sorted-ii
delete-columns-to-make-sorted-ii__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\nYou are given an array of n strings strs, all of the same length.\n\nWe ma...
tallest-billboard
tallest-billboard__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 installing a billboard and want it to have the largest height. The...
tallest-billboard
tallest-billboard__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 installing a billboard and want it to have the largest height. The...
prison-cells-after-n-days
prison-cells-after-n-days__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\nThere are 8 prison cells in a row and each cell is either occupied or vaca...
check-completeness-of-a-binary-tree
check-completeness-of-a-binary-tree__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\nGiven the root of a binary tree, determine if it is a complete binary tree...
regions-cut-by-slashes
regions-cut-by-slashes__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\nAn n x n grid is composed of 1 x 1 squares where each 1 x 1 square consist...
delete-columns-to-make-sorted-iii
delete-columns-to-make-sorted-iii__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 array of n strings strs, all of the same length.\n\nWe ma...
n-repeated-element-in-size-2n-array
n-repeated-element-in-size-2n-array__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 an integer array nums with the following properties:\n\n\tnu...
n-repeated-element-in-size-2n-array
n-repeated-element-in-size-2n-array__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 with the following properties:\n\n\tnu...
maximum-width-ramp
maximum-width-ramp__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\nA ramp in an integer array nums is a pair (i, j) for which i < j and nums[...
minimum-area-rectangle-ii
minimum-area-rectangle-ii__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 an array of points in the X-Y plane points where points[i] =...
least-operators-to-express-number
least-operators-to-express-number__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\nGiven a single positive integer x, we will write an expression of the form...
univalued-binary-tree
univalued-binary-tree__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\nA binary tree is uni-valued if every node in the tree has the same value.\...
vowel-spellchecker
vowel-spellchecker__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 wordlist, we want to implement a spellchecker that converts a quer...
numbers-with-same-consecutive-differences
numbers-with-same-consecutive-differences__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 two integers n and k, return an array of all the integers of length ...
binary-tree-cameras
binary-tree-cameras__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 the root of a binary tree. We install cameras on the tree no...
pancake-sorting
pancake-sorting__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\nGiven an array of integers arr, sort the array by performing a series of p...
powerful-integers
powerful-integers__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 three integers x, y, and bound, return a list of all the powerful in...
flip-binary-tree-to-match-preorder-traversal
flip-binary-tree-to-match-preorder-traversal__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 the root of a binary tree with n nodes, where each node is u...
equal-rational-numbers
equal-rational-numbers__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 two strings s and t, each of which represents a non-negative rationa...
k-closest-points-to-origin
k-closest-points-to-origin__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\nGiven an array of points where points[i] = [xi, yi] represents a point on ...
k-closest-points-to-origin
k-closest-points-to-origin__02__java
Heap
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 points where points[i] = [xi, yi] represents a point on ...
k-closest-points-to-origin
k-closest-points-to-origin__03__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\nGiven an array of points where points[i] = [xi, yi] represents a point on ...
subarray-sums-divisible-by-k
subarray-sums-divisible-by-k__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 an integer array nums and an integer k, return the number of non-emp...
odd-even-jump
odd-even-jump__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 are given an integer array arr. From some starting index, you can make...
largest-perimeter-triangle
largest-perimeter-triangle__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\nGiven an integer array nums, return the largest perimeter of a triangle wi...
squares-of-a-sorted-array
squares-of-a-sorted-array__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 sorted in non-decreasing order, return an arra...
longest-turbulent-subarray
longest-turbulent-subarray__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 integer array arr, return the length of a maximum size turbulent ...
distribute-coins-in-binary-tree
distribute-coins-in-binary-tree__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 the root of a binary tree with n nodes where each node in th...
unique-paths-iii
unique-paths-iii__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 an m x n integer array grid where grid[i][j] could be:\n\n\t...
time-based-key-value-store
time-based-key-value-store__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\nDesign a time-based key-value data structure that can store multiple value...
triples-with-bitwise-and-equal-to-zero
triples-with-bitwise-and-equal-to-zero__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\nGiven an integer array nums, return the number of AND triples.\n\nAn AND t...
minimum-cost-for-tickets
minimum-cost-for-tickets__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 planned some train traveling one year in advance. The days of the...
minimum-cost-for-tickets
minimum-cost-for-tickets__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 planned some train traveling one year in advance. The days of the...
string-without-aaa-or-bbb
string-without-aaa-or-bbb__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\nGiven two integers a and b, return any string s such that:\n\n\ts has leng...
sum-of-even-numbers-after-queries
sum-of-even-numbers-after-queries__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 integer array nums and an array queries where queries[i] ...
interval-list-intersections
interval-list-intersections__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 two lists of closed intervals, firstList and secondList, whe...
vertical-order-traversal-of-a-binary-tree
vertical-order-traversal-of-a-binary-tree__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 tree, calculate the vertical order traversal of...
smallest-string-starting-from-leaf
smallest-string-starting-from-leaf__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 the root of a binary tree where each node has a value in the...
add-to-array-form-of-integer
add-to-array-form-of-integer__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 array-form of an integer num is an array representing its digits in le...
satisfiability-of-equality-equations
satisfiability-of-equality-equations__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 array of strings equations that represent relationships b...
broken-calculator
broken-calculator__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 broken calculator that has the integer startValue on its displa...
subarrays-with-k-different-integers
subarrays-with-k-different-integers__01__java
Sliding Window
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 an integer k, return the number of good su...
cousins-in-binary-tree
cousins-in-binary-tree__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 tree with unique values and the values of two d...
cousins-in-binary-tree
cousins-in-binary-tree__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\nGiven the root of a binary tree with unique values and the values of two d...
rotting-oranges
rotting-oranges__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 m x n grid where each cell can have one of three values:\...
minimum-number-of-k-consecutive-bit-flips
minimum-number-of-k-consecutive-bit-flips__01__java
Sliding Window
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 binary array nums and an integer k.\n\nA k-bit flip is cho...
minimum-number-of-k-consecutive-bit-flips
minimum-number-of-k-consecutive-bit-flips__02__java
Sliding Window
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 binary array nums and an integer k.\n\nA k-bit flip is cho...
number-of-squareful-arrays
number-of-squareful-arrays__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 array is squareful if the sum of every pair of adjacent elements is a p...
find-the-town-judge
find-the-town-judge__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\nIn a town, there are n people labeled from 1 to n. There is a rumor that o...
maximum-binary-tree-ii
maximum-binary-tree-ii__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\nA maximum tree is a tree where every node has a value greater than any oth...
maximum-binary-tree-ii
maximum-binary-tree-ii__02__java
Brute Force
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 maximum tree is a tree where every node has a value greater than any oth...
available-captures-for-rook
available-captures-for-rook__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 8 x 8 matrix representing a chessboard. There is exactly ...
minimum-cost-to-merge-stones
minimum-cost-to-merge-stones__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 piles of stones arranged in a row. The ith pile has stones[i] ...
grid-illumination
grid-illumination__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 a 2D grid of size n x n where each cell of this grid has a lamp t...
find-common-characters
find-common-characters__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 array words, return an array of all characters that show up...
check-if-word-is-valid-after-substitutions
check-if-word-is-valid-after-substitutions__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 string s, determine if it is valid.\n\nA string s is valid if, sta...
max-consecutive-ones-iii
max-consecutive-ones-iii__01__java
Sliding Window
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 binary array nums and an integer k, return the maximum number of c...
maximize-sum-of-array-after-k-negations
maximize-sum-of-array-after-k-negations__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\nGiven an integer array nums and an integer k, modify the array in the foll...
clumsy-factorial
clumsy-factorial__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 factorial of a positive integer n is the product of all positive integ...
minimum-domino-rotations-for-equal-row
minimum-domino-rotations-for-equal-row__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\nIn a row of dominoes, tops[i] and bottoms[i] represent the top and bottom ...
construct-binary-search-tree-from-preorder-traversal
construct-binary-search-tree-from-preorder-traversal__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\nGiven an array of integers preorder, which represents the preorder travers...
complement-of-base-10-integer
complement-of-base-10-integer__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\nThe complement of an integer is the integer you get when you flip all the ...
pairs-of-songs-with-total-durations-divisible-by-60
pairs-of-songs-with-total-durations-divisible-by-60__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 list of songs where the ith song has a duration of time[i]...
capacity-to-ship-packages-within-d-days
capacity-to-ship-packages-within-d-days__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\nA conveyor belt has packages that must be shipped from one port to another...
numbers-with-repeated-digits
numbers-with-repeated-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\nGiven an integer n, return the number of positive integers in the range [1...
partition-array-into-three-parts-with-equal-sum
partition-array-into-three-parts-with-equal-sum__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\nGiven an array of integers arr, return true if we can partition the array ...
best-sightseeing-pair
best-sightseeing-pair__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 values where values[i] represents the value...
smallest-integer-divisible-by-k
smallest-integer-divisible-by-k__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 a positive integer k, you need to find the length of the smallest po...
binary-string-with-substrings-representing-1-to-n
binary-string-with-substrings-representing-1-to-n__01__java
Sliding Window
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 binary string s and a positive integer n, return true if the binar...
convert-to-base-2
convert-to-base-2__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 a binary string representing its representation...
binary-prefix-divisible-by-5
binary-prefix-divisible-by-5__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 binary array nums (0-indexed).\n\nWe define xi as the numb...
next-greater-node-in-linked-list
next-greater-node-in-linked-list__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 with n nodes.\n\nFor each node in ...
number-of-enclaves
number-of-enclaves__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 m x n binary matrix grid, where 0 represents a sea cell a...
number-of-enclaves
number-of-enclaves__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\nYou are given an m x n binary matrix grid, where 0 represents a sea cell a...
number-of-enclaves
number-of-enclaves__03__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 m x n binary matrix grid, where 0 represents a sea cell a...
remove-outermost-parentheses
remove-outermost-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\nA valid parentheses string is either empty \"\", \"(\" + A + \")\", or A +...
remove-outermost-parentheses
remove-outermost-parentheses__02__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\nA valid parentheses string is either empty \"\", \"(\" + A + \")\", or A +...
sum-of-root-to-leaf-binary-numbers
sum-of-root-to-leaf-binary-numbers__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\nYou are given the root of a binary tree where each node has a value 0 or 1...
camelcase-matching
camelcase-matching__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 array of strings queries and a string pattern, return a boolean a...
video-stitching
video-stitching__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\nYou are given a series of video clips from a sporting event that lasted ti...
divisor-game
divisor-game__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\nAlice and Bob take turns playing a game, with Alice starting first.\n\nIni...
maximum-difference-between-node-and-ancestor
maximum-difference-between-node-and-ancestor__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 tree, find the maximum value v for which there ...
longest-arithmetic-subsequence
longest-arithmetic-subsequence__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 nums of integers, return the length of the longest arithmet...
recover-a-tree-from-preorder-traversal
recover-a-tree-from-preorder-traversal__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\nWe run a preorder depth-first search (DFS) on the root of a binary tree.\n...
two-city-scheduling
two-city-scheduling__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\nA company is planning to interview 2n people. Given the array costs where ...