slug
stringlengths
3
79
solution_id
stringlengths
13
89
primary_algorithm
stringclasses
22 values
verified
null
messages
listlengths
3
3
shortest-word-distance-iii
shortest-word-distance-iii__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 an array of strings wordsDict and two strings that already exist in ...
strobogrammatic-number
strobogrammatic-number__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 num which represents an integer, return true if num is a st...
strobogrammatic-number-ii
strobogrammatic-number-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\nGiven an integer n, return all the strobogrammatic numbers that are of len...
strobogrammatic-number-iii
strobogrammatic-number-iii__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 two strings low and high that represent two integers low and high wh...
group-shifted-strings
group-shifted-strings__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\nPerform the following shift operations on a string:\n\n\tRight shift: Repl...
count-univalue-subtrees
count-univalue-subtrees__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, return the number of uni-value subtrees.\...
flatten-2d-vector
flatten-2d-vector__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\nDesign an iterator to flatten a 2D vector. It should support the next and ...
meeting-rooms
meeting-rooms__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 array of meeting times intervals where intervals[i] = [st...
meeting-rooms-ii
meeting-rooms-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\nGiven an array of meeting time intervals intervals where intervals[i] = [s...
meeting-rooms-ii
meeting-rooms-ii__02__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 array of meeting time intervals intervals where intervals[i] = [s...
factor-combinations
factor-combinations__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\nNumbers can be regarded as the product of their factors.\n\n\tFor example,...
verify-preorder-sequence-in-binary-search-tree
verify-preorder-sequence-in-binary-search-tree__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 an array of unique integers preorder, return true if it is the corre...
paint-house
paint-house__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 a row of n houses, where each house can be painted one of three c...
add-digits
add-digits__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 num, repeatedly add all its digits until the result has o...
3sum-smaller
3sum-smaller__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 n integers nums and an integer target, find the number o...
single-number-iii
single-number-iii__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, in which exactly two elements appear only onc...
graph-valid-tree
graph-valid-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 have a graph of n nodes labeled from 0 to n - 1. You are given an inte...
graph-valid-tree
graph-valid-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\nYou have a graph of n nodes labeled from 0 to n - 1. You are given an inte...
ugly-number
ugly-number__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 ugly number is a positive integer which does not have a prime factor ot...
ugly-number-ii
ugly-number-ii__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 ugly number is a positive integer whose prime factors are limited to 2,...
ugly-number-ii
ugly-number-ii__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 ugly number is a positive integer whose prime factors are limited to 2,...
paint-house-ii
paint-house-ii__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 a row of n houses, each house can be painted with one of the k c...
palindrome-permutation
palindrome-permutation__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 a string s, return true if a permutation of the string could form a ...
palindrome-permutation-ii
palindrome-permutation-ii__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 string s, return all the palindromic permutations (without duplica...
missing-number
missing-number__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 nums containing n distinct numbers in the range [0, n], ret...
missing-number
missing-number__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\nGiven an array nums containing n distinct numbers in the range [0, n], ret...
alien-dictionary
alien-dictionary__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 new alien language that uses the English alphabet. However, the...
closest-binary-search-tree-value
closest-binary-search-tree-value__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 and a target value, return the valu...
closest-binary-search-tree-value
closest-binary-search-tree-value__02__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 the root of a binary search tree and a target value, return the valu...
encode-and-decode-strings
encode-and-decode-strings__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\nDesign an algorithm to encode a list of strings to a string. The encoded s...
closest-binary-search-tree-value-ii
closest-binary-search-tree-value-ii__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 the root of a binary search tree, a target value, and an integer k, ...
integer-to-english-words
integer-to-english-words__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\nConvert a non-negative integer num to its English words representation.\n\...
h-index
h-index__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 integers citations where citations[i] is the number of c...
h-index
h-index__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\nGiven an array of integers citations where citations[i] is the number of c...
h-index
h-index__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 integers citations where citations[i] is the number of c...
h-index-ii
h-index-ii__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 citations where citations[i] is the number of c...
paint-fence
paint-fence__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 painting a fence of n posts with k different colors. You must pain...
paint-fence
paint-fence__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 painting a fence of n posts with k different colors. You must pain...
find-the-celebrity
find-the-celebrity__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\nSuppose you are at a party with n people labeled from 0 to n - 1 and among...
first-bad-version
first-bad-version__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 a product manager and currently leading a team to develop a new pr...
perfect-squares
perfect-squares__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 least number of perfect square numbers that...
perfect-squares
perfect-squares__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 an integer n, return the least number of perfect square numbers that...
wiggle-sort
wiggle-sort__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, reorder it such that nums[0] <= nums[1] >= nu...
zigzag-iterator
zigzag-iterator__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 two vectors of integers v1 and v2, implement an iterator to return t...
expression-add-operators
expression-add-operators__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 string num that contains only digits and an integer target, return...
move-zeroes
move-zeroes__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, move all 0's to the end of it while maintaini...
peeking-iterator
peeking-iterator__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\nDesign an iterator that supports the peek operation on an existing iterato...
inorder-successor-in-bst
inorder-successor-in-bst__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 the root of a binary search tree and a node p in it, return the in-o...
walls-and-gates
walls-and-gates__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 rooms initialized with these three possible va...
find-the-duplicate-number
find-the-duplicate-number__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 nums containing n + 1 integers where each integ...
unique-word-abbreviation
unique-word-abbreviation__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\nThe abbreviation of a word is a concatenation of its first letter, the num...
game-of-life
game-of-life__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\nAccording to Wikipedia's article: \"The Game of Life, also known simply as...
word-pattern
word-pattern__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 pattern and a string s, find if s follows the same pattern.\n\nHer...
word-pattern-ii
word-pattern-ii__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 pattern and a string s, return true if s matches the pattern.\n\nA...
nim-game
nim-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\nYou are playing the following Nim Game with your friend:\n\n\tInitially, t...
flip-game
flip-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\nYou are playing a Flip Game with your friend.\n\nYou are given a string cu...
flip-game-ii
flip-game-ii__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 playing a Flip Game with your friend.\n\nYou are given a string cu...
flip-game-ii
flip-game-ii__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 playing a Flip Game with your friend.\n\nYou are given a string cu...
find-median-from-data-stream
find-median-from-data-stream__01__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\nThe median is the middle value in an ordered integer list. If the size of ...
best-meeting-point
best-meeting-point__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 m x n binary grid grid where each 1 marks the home of one friend,...
serialize-and-deserialize-binary-tree
serialize-and-deserialize-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\nSerialization is the process of converting a data structure or object into...
binary-tree-longest-consecutive-sequence
binary-tree-longest-consecutive-sequence__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, return the length of the longest consecut...
bulls-and-cows
bulls-and-cows__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 playing the Bulls and Cows game with your friend.\n\nYou write dow...
longest-increasing-subsequence
longest-increasing-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 integer array nums, return the length of the longest strictly inc...
longest-increasing-subsequence
longest-increasing-subsequence__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 an integer array nums, return the length of the longest strictly inc...
remove-invalid-parentheses
remove-invalid-parentheses__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 string s that contains parentheses and letters, remove the minimum...
smallest-rectangle-enclosing-black-pixels
smallest-rectangle-enclosing-black-pixels__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 m x n binary matrix image where 0 represents a white pixe...
range-sum-query-immutable
range-sum-query-immutable__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 an integer array nums, handle multiple queries of the following type...
range-sum-query-2d-immutable
range-sum-query-2d-immutable__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 2D matrix matrix, handle multiple queries of the following type:\n...
number-of-islands-ii
number-of-islands-ii__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 empty 2D binary grid grid of size m x n. The grid represe...
additive-number
additive-number__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\nAn additive number is a string whose digits can form an additive sequence....
range-sum-query-mutable
range-sum-query-mutable__01__java
Divide and Conquer
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, handle multiple queries of the following type...
range-sum-query-mutable
range-sum-query-mutable__02__java
Divide and Conquer
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, handle multiple queries of the following type...
range-sum-query-2d-mutable
range-sum-query-2d-mutable__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 2D matrix matrix, handle multiple queries of the following types:\...
range-sum-query-2d-mutable
range-sum-query-2d-mutable__02__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 2D matrix matrix, handle multiple queries of the following types:\...
best-time-to-buy-and-sell-stock-with-cooldown
best-time-to-buy-and-sell-stock-with-cooldown__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 array prices where prices[i] is the price of a given stoc...
best-time-to-buy-and-sell-stock-with-cooldown
best-time-to-buy-and-sell-stock-with-cooldown__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 array prices where prices[i] is the price of a given stoc...
best-time-to-buy-and-sell-stock-with-cooldown
best-time-to-buy-and-sell-stock-with-cooldown__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\nYou are given an array prices where prices[i] is the price of a given stoc...
minimum-height-trees
minimum-height-trees__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\nA tree is an undirected graph in which any two vertices are connected by e...
sparse-matrix-multiplication
sparse-matrix-multiplication__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 two sparse matrices mat1 of size m x k and mat2 of size k x n, retur...
sparse-matrix-multiplication
sparse-matrix-multiplication__02__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 two sparse matrices mat1 of size m x k and mat2 of size k x n, retur...
burst-balloons
burst-balloons__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 n balloons, indexed from 0 to n - 1. Each balloon is painted...
super-ugly-number
super-ugly-number__01__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\nA super ugly number is a positive integer whose prime factors are in the a...
binary-tree-vertical-order-traversal
binary-tree-vertical-order-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\nGiven the root of a binary tree, return the vertical order traversal of it...
binary-tree-vertical-order-traversal
binary-tree-vertical-order-traversal__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\nGiven the root of a binary tree, return the vertical order traversal of it...
count-of-smaller-numbers-after-self
count-of-smaller-numbers-after-self__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 integer array nums, return an integer array counts where counts[i...
count-of-smaller-numbers-after-self
count-of-smaller-numbers-after-self__02__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 integer array nums, return an integer array counts where counts[i...
remove-duplicate-letters
remove-duplicate-letters__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 a string s, remove duplicate letters so that every letter appears on...
shortest-distance-from-all-buildings
shortest-distance-from-all-buildings__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 grid of values 0, 1, or 2, where:\n\n\teach 0 ...
maximum-product-of-word-lengths
maximum-product-of-word-lengths__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 a string array words, return the maximum value of length(word[i]) * ...
maximum-product-of-word-lengths
maximum-product-of-word-lengths__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\nGiven a string array words, return the maximum value of length(word[i]) * ...
bulb-switcher
bulb-switcher__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\nThere are n bulbs that are initially off. You first turn on all the bulbs,...
generalized-abbreviation
generalized-abbreviation__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 word's generalized abbreviation can be constructed by taking any number ...
generalized-abbreviation
generalized-abbreviation__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\nA word's generalized abbreviation can be constructed by taking any number ...
create-maximum-number
create-maximum-number__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 two integer arrays nums1 and nums2 of lengths m and n respec...
coin-change
coin-change__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 coins representing coins of different denom...
number-of-connected-components-in-an-undirected-graph
number-of-connected-components-in-an-undirected-graph__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 have a graph of n nodes. You are given an integer n and an array edges...
number-of-connected-components-in-an-undirected-graph
number-of-connected-components-in-an-undirected-graph__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 have a graph of n nodes. You are given an integer n and an array edges...
number-of-connected-components-in-an-undirected-graph
number-of-connected-components-in-an-undirected-graph__03__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 have a graph of n nodes. You are given an integer n and an array edges...
wiggle-sort-ii
wiggle-sort-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\nGiven an integer array nums, reorder it such that nums[0] < nums[1] > nums...