slug
stringlengths
3
79
solution_id
stringlengths
13
89
primary_algorithm
stringclasses
22 values
verified
null
messages
listlengths
3
3
minimum-cost-to-hire-k-workers
minimum-cost-to-hire-k-workers__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 are n workers. You are given two integer arrays quality and wage whe...
mirror-reflection
mirror-reflection__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 is a special square room with mirrors on each of the four walls. Exc...
buddy-strings
buddy-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\nGiven two strings s and goal, return true if you can swap two letters in s...
lemonade-change
lemonade-change__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\nAt a lemonade stand, each lemonade costs $5. Customers are standing in a q...
score-after-flipping-matrix
score-after-flipping-matrix__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 m x n binary matrix grid.\n\nA move consists of choosing ...
shortest-subarray-with-sum-at-least-k
shortest-subarray-with-sum-at-least-k__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 length of the sho...
all-nodes-distance-k-in-binary-tree
all-nodes-distance-k-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, the value of a target node target, and an...
shortest-path-to-get-all-keys
shortest-path-to-get-all-keys__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 where:\n\n\t'.' is an empty cell.\n\t'#' ...
smallest-subtree-with-all-the-deepest-nodes
smallest-subtree-with-all-the-deepest-nodes__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, the depth of each node is the shortest di...
prime-palindrome
prime-palindrome__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 smallest prime palindrome greater than or e...
transpose-matrix
transpose-matrix__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 2D integer array matrix, return the transpose of matrix.\n\nThe tr...
binary-gap
binary-gap__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 positive integer n, find and return the longest distance between a...
reordered-power-of-2
reordered-power-of-2__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 n. We reorder the digits in any order (including ...
advantage-shuffle
advantage-shuffle__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 both of the same length. ...
minimum-number-of-refueling-stops
minimum-number-of-refueling-stops__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 car travels from a starting position to a destination which is target mi...
leaf-similar-trees
leaf-similar-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\nConsider all the leaves of a binary tree, from left to right order, the va...
length-of-longest-fibonacci-subsequence
length-of-longest-fibonacci-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\nA sequence x1, x2, ..., xn is Fibonacci-like if:\n\n\tn >= 3\n\txi + xi+1 ...
walking-robot-simulation
walking-robot-simulation__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 robot on an infinite XY-plane starts at point (0, 0) facing north. The r...
koko-eating-bananas
koko-eating-bananas__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\nKoko loves to eat bananas. There are n piles of bananas, the ith pile has ...
middle-of-the-linked-list
middle-of-the-linked-list__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 head of a singly linked list, return the middle node of the link...
stone-game
stone-game__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\nAlice and Bob play a game with piles of stones. There are an even number o...
stone-game
stone-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 and Bob play a game with piles of stones. There are an even number o...
nth-magical-number
nth-magical-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\nA positive integer is magical if it is divisible by either a or b.\n\nGive...
profitable-schemes
profitable-schemes__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\nThere is a group of n members, and a list of various crimes they could com...
profitable-schemes
profitable-schemes__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 is a group of n members, and a list of various crimes they could com...
decoded-string-at-index
decoded-string-at-index__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 an encoded string s. To decode the string to a tape, the enc...
boats-to-save-people
boats-to-save-people__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 people where people[i] is the weight of the ith per...
reachable-nodes-in-subdivided-graph
reachable-nodes-in-subdivided-graph__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 undirected graph (the \"original graph\") with n nodes la...
projection-area-of-3d-shapes
projection-area-of-3d-shapes__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 n x n grid where we place some 1 x 1 x 1 cubes that are a...
uncommon-words-from-two-sentences
uncommon-words-from-two-sentences__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 sentence is a string of single-space separated words where each word con...
spiral-matrix-iii
spiral-matrix-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\nYou start at the cell (rStart, cStart) of an rows x cols grid facing east....
possible-bipartition
possible-bipartition__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 want to split a group of n people (labeled from 1 to n) into two groups...
possible-bipartition
possible-bipartition__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\nWe want to split a group of n people (labeled from 1 to n) into two groups...
super-egg-drop
super-egg-drop__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 k identical eggs and you have access to a building with n fl...
super-egg-drop
super-egg-drop__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 k identical eggs and you have access to a building with n fl...
fair-candy-swap
fair-candy-swap__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\nAlice and Bob have a different total number of candies. You are given two ...
construct-binary-tree-from-preorder-and-postorder-traversal
construct-binary-tree-from-preorder-and-postorder-traversal__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 integer arrays, preorder and postorder where preorder is the pre...
construct-binary-tree-from-preorder-and-postorder-traversal
construct-binary-tree-from-preorder-and-postorder-traversal__02__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 integer arrays, preorder and postorder where preorder is the pre...
find-and-replace-pattern
find-and-replace-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 list of strings words and a string pattern, return a list of words...
sum-of-subsequence-widths
sum-of-subsequence-widths__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\nThe width of a sequence is the difference between the maximum and minimum ...
surface-area-of-3d-shapes
surface-area-of-3d-shapes__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 n x n grid where you have placed some 1 x 1 x 1 cubes. Ea...
groups-of-special-equivalent-strings
groups-of-special-equivalent-strings__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 strings of the same length words.\n\nIn one move...
all-possible-full-binary-trees
all-possible-full-binary-trees__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 an integer n, return a list of all possible full binary trees with n...
maximum-frequency-stack
maximum-frequency-stack__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\nDesign a stack-like data structure to push elements to the stack and pop t...
maximum-frequency-stack
maximum-frequency-stack__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\nDesign a stack-like data structure to push elements to the stack and pop t...
monotonic-array
monotonic-array__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\nAn array is monotonic if it is either monotone increasing or monotone decr...
increasing-order-search-tree
increasing-order-search-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 search tree, rearrange the tree in in-order so ...
bitwise-ors-of-subarrays
bitwise-ors-of-subarrays__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 arr, return the number of distinct bitwise ORs of a...
orderly-queue
orderly-queue__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 a string s and an integer k. You can choose one of the first...
rle-iterator
rle-iterator__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\nWe can use run-length encoding (i.e., RLE) to encode a sequence of integer...
online-stock-span
online-stock-span__01__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\nDesign an algorithm that collects daily price quotes for some stock and re...
numbers-at-most-n-given-digit-set
numbers-at-most-n-given-digit-set__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 digits which is sorted in non-decreasing order. You can ...
valid-permutations-for-di-sequence
valid-permutations-for-di-sequence__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 a string s of length n where s[i] is either:\n\n\t'D' means ...
fruit-into-baskets
fruit-into-baskets__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 visiting a farm that has a single row of fruit trees arranged from...
fruit-into-baskets
fruit-into-baskets__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 visiting a farm that has a single row of fruit trees arranged from...
sort-array-by-parity
sort-array-by-parity__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 the even integers at the beginning o...
super-palindromes
super-palindromes__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\nLet's say a positive integer is a super-palindrome if it is a palindrome, ...
sum-of-subarray-minimums
sum-of-subarray-minimums__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 integers arr, find the sum of min(b), where b ranges ove...
smallest-range-i
smallest-range-i__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 integer k.\n\nIn one operation,...
snakes-and-ladders
snakes-and-ladders__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 n x n integer matrix board where the cells are labeled fr...
smallest-range-ii
smallest-range-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 integer array nums and an integer k.\n\nFor each index i ...
online-election
online-election__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 two integer arrays persons and times. In an election, the it...
sort-an-array
sort-an-array__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 array of integers nums, sort the array in ascending order and ret...
sort-an-array
sort-an-array__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 array of integers nums, sort the array in ascending order and ret...
sort-an-array
sort-an-array__03__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 array of integers nums, sort the array in ascending order and ret...
cat-and-mouse
cat-and-mouse__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 game on an undirected graph is played by two players, Mouse and Cat, who...
x-of-a-kind-in-a-deck-of-cards
x-of-a-kind-in-a-deck-of-cards__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 deck where deck[i] represents the number wr...
partition-array-into-disjoint-intervals
partition-array-into-disjoint-intervals__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, partition it into two (contiguous) subarrays ...
word-subsets
word-subsets__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 string arrays words1 and words2.\n\nA string b is a subs...
reverse-only-letters
reverse-only-letters__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, reverse the string according to the following rules:\n\n...
maximum-sum-circular-subarray
maximum-sum-circular-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 a circular integer array nums of length n, return the maximum possib...
complete-binary-tree-inserter
complete-binary-tree-inserter__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\nA complete binary tree is a binary tree in which every level, except possi...
number-of-music-playlists
number-of-music-playlists__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 music player contains n different songs. You want to listen to goal s...
number-of-music-playlists
number-of-music-playlists__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\nYour music player contains n different songs. You want to listen to goal s...
minimum-add-to-make-parentheses-valid
minimum-add-to-make-parentheses-valid__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 parentheses string is valid if and only if:\n\n\tIt is the empty string,...
minimum-add-to-make-parentheses-valid
minimum-add-to-make-parentheses-valid__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\nA parentheses string is valid if and only if:\n\n\tIt is the empty string,...
sort-array-by-parity-ii
sort-array-by-parity-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 an array of integers nums, half of the integers in nums are odd, and...
3sum-with-multiplicity
3sum-with-multiplicity__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 arr, and an integer target, return the number of tu...
minimize-malware-spread
minimize-malware-spread__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 a network of n nodes represented as an n x n adjacency matri...
long-pressed-name
long-pressed-name__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\nYour friend is typing his name into a keyboard. Sometimes, when typing a c...
flip-string-to-monotone-increasing
flip-string-to-monotone-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\nA binary string is monotone increasing if it consists of some number of 0'...
three-equal-parts
three-equal-parts__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 arr which consists of only zeros and ones, divide t...
minimize-malware-spread-ii
minimize-malware-spread-ii__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 a network of n nodes represented as an n x n adjacency matri...
unique-email-addresses
unique-email-addresses__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\nEvery valid email consists of a local name and a domain name, separated by...
binary-subarrays-with-sum
binary-subarrays-with-sum__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 goal, return the number of non-em...
binary-subarrays-with-sum
binary-subarrays-with-sum__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\nGiven a binary array nums and an integer goal, return the number of non-em...
minimum-falling-path-sum
minimum-falling-path-sum__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 n x n array of integers matrix, return the minimum sum of any fal...
beautiful-array
beautiful-array__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\nAn array nums of length n is beautiful if:\n\n\tnums is a permutation of t...
number-of-recent-calls
number-of-recent-calls__01__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\nYou have a RecentCounter class which counts the number of recent requests ...
shortest-bridge
shortest-bridge__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 where 1 represents land and 0 re...
knight-dialer
knight-dialer__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\nThe chess knight has a unique movement, it may move two squares vertically...
knight-dialer
knight-dialer__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\nThe chess knight has a unique movement, it may move two squares vertically...
stamping-the-sequence
stamping-the-sequence__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 stamp and target. Initially, there is a string s...
reorder-data-in-log-files
reorder-data-in-log-files__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 logs. Each log is a space-delimited string of wo...
range-sum-of-bst
range-sum-of-bst__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 node of a binary search tree and two integers low and high,...
minimum-area-rectangle
minimum-area-rectangle__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 points in the X-Y plane points where points[i] =...
distinct-subsequences-ii
distinct-subsequences-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\nGiven a string s, return the number of distinct non-empty subsequences of ...
distinct-subsequences-ii
distinct-subsequences-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\nGiven a string s, return the number of distinct non-empty subsequences of ...
valid-mountain-array
valid-mountain-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 array of integers arr, return true if and only if it is a valid m...
di-string-match
di-string-match__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 permutation perm of n + 1 integers of all the integers in the range [0, ...