slug
stringlengths
3
79
solution_id
stringlengths
13
89
primary_algorithm
stringclasses
22 values
verified
null
messages
listlengths
3
3
valid-digit-number
valid-digit-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\nYou are given an integer n and a digit x.\n\nA number is considered valid ...
compare-sums-of-bitonic-parts
compare-sums-of-bitonic-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 a bitonic array nums of length n.\n\nSplit the array into tw...
count-connected-subgraphs-with-even-node-sum
count-connected-subgraphs-with-even-node-sum__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 undirected graph with n nodes labeled from 0 to n - 1. No...
k-th-smallest-remaining-even-integer-in-subarray-queries
k-th-smallest-remaining-even-integer-in-subarray-queries__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 are given an integer array nums where nums is strictly increasing.\n\n...
valid-elements-in-an-array
valid-elements-in-an-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\nYou are given an integer array nums.\n\nAn element nums[i] is considered v...
sort-vowels-by-frequency
sort-vowels-by-frequency__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 consisting of lowercase English characters.\n\nRe...
minimum-operations-to-make-array-non-decreasing
minimum-operations-to-make-array-non-decreasing__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 of length n.\n\nIn one operation, you ...
maximum-sum-of-alternating-subsequence-with-distance-at-least-k
maximum-sum-of-alternating-subsequence-with-distance-at-least-k__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums of length n and an integer k.\n\nPick ...
number-of-zigzag-arrays-iii
number-of-zigzag-arrays-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 three integers n, l, and r.\n\nA ZigZag array of length n is...
count-indices-with-opposite-parity
count-indices-with-opposite-parity__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 integer array nums of length n.\n\nThe score of an index ...
sum-of-primes-between-number-and-its-reverse
sum-of-primes-between-number-and-its-reverse__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 n.\n\nLet r be the integer formed by reversing th...
minimum-cost-to-move-between-indices
minimum-cost-to-move-between-indices__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 where nums is strictly increasing.\n\n...
maximize-fixed-points-after-deletions
maximize-fixed-points-after-deletions__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 are given an integer array nums.\n\nA position i is called a fixed poi...
score-validator
score-validator__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a string array events.\n\nInitially, score = 0 and counter =...
minimum-flips-to-make-binary-string-coherent
minimum-flips-to-make-binary-string-coherent__01__java
String
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a binary string s.\n\nA string is considered coherent if it ...
minimum-generations-to-target-point
minimum-generations-to-target-point__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 a 2D integer array points where points[i] = [xi, yi, zi] rep...
minimum-threshold-path-with-limited-heavy-edges
minimum-threshold-path-with-limited-heavy-edges__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\nThere is an undirected weighted graph with n nodes labeled from 0 to n - 1...
concatenate-array-with-reverse
concatenate-array-with-reverse__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 of length n.\n\nConstruct a new array ...
count-valid-word-occurrences
count-valid-word-occurrences__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 are given an array of strings chunks. Concatenate all strings in chunk...
minimize-array-sum-using-divisible-replacements
minimize-array-sum-using-divisible-replacements__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.\n\nYou can perform the following oper...
minimum-cost-to-buy-apples-ii
minimum-cost-to-buy-apples-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 integer n and an integer array prices of length n, where ...
minimum-partition-score-ii
minimum-partition-score-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 given an integer array nums and an integer k.\n\nYour task is to p...
check-adjacent-digit-differences
check-adjacent-digit-differences__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a string s consisting of digits.\n\nReturn true if the absol...
count-k-th-roots-in-a-range
count-k-th-roots-in-a-range__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 three integers l, r, and k.\n\nAn integer y is said to be a ...
largest-local-values-in-a-matrix-ii
largest-local-values-in-a-matrix-ii__01__java
Array
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an n x m integer matrix matrix containing non-negative integ...
power-update-after-k-th-largest-insertion-i
power-update-after-k-th-largest-insertion-i__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 nums and an integer p.\n\nYou are also give...
minimum-swaps-to-move-zeros-to-end
minimum-swaps-to-move-zeros-to-end__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 an integer array nums.\n\nIn one operation, you can choose a...
minimum-operations-to-make-array-modulo-alternating-i
minimum-operations-to-make-array-modulo-alternating-i__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 integer array nums and an integer k.\n\nIn one operation,...
maximum-path-intersection-sum-in-a-grid
maximum-path-intersection-sum-in-a-grid__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 m x n integer matrix grid.\n\nTwo players move across the...
count-non-adjacent-subsets-in-a-rooted-tree
count-non-adjacent-subsets-in-a-rooted-tree__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a rooted tree with n nodes labeled from 0 to n - 1, represen...
limit-occurrences-in-sorted-array
limit-occurrences-in-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\nYou are given a sorted integer array nums and an integer k.\n\nReturn an a...
password-strength
password-strength__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 a string password.\n\nThe strength of the password is calcul...
minimum-operations-to-sort-a-permutation
minimum-operations-to-sort-a-permutation__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 integer array nums of length n, where nums is a permutati...
number-of-pairs-after-increment
number-of-pairs-after-increment__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\nYou are given two integer arrays nums1 and nums2, and a 2D integer array q...
minimum-operations-to-make-array-modulo-alternating-ii
minimum-operations-to-make-array-modulo-alternating-ii__01__java
Array
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums and an integer k.\n\nIn one operation,...
digit-frequency-score
digit-frequency-score__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 n.\n\nThe score of n is defined as the sum of d *...
maximum-number-of-items-from-sale-i
maximum-number-of-items-from-sale-i__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 2D integer array items, where items[i] = [factori, pricei]...
maximum-number-of-items-from-sale-ii
maximum-number-of-items-from-sale-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 a 2D integer array items, where items[i] = [factori, pricei]...
lexicographically-maximum-mex-array
lexicographically-maximum-mex-array__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.\n\nYou want to construct an array res...
subtree-inversion-sum-ii
subtree-inversion-sum-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 given an undirected tree rooted at node 0, with n nodes numbered f...
exactly-one-consecutive-set-bits-pair
exactly-one-consecutive-set-bits-pair__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 n.\n\nReturn true if its binary representation co...
minimum-energy-to-maintain-brightness
minimum-energy-to-maintain-brightness__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, representing n light bulbs arranged in a line ...
maximum-total-value-of-covered-indices
maximum-total-value-of-covered-indices__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums of length n and a binary string s of l...
maximum-score-with-co-prime-element
maximum-score-with-co-prime-element__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 of length n and an integer maxVal.\n\n...
sum-of-compatible-numbers-in-range-i
sum-of-compatible-numbers-in-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 two integers n and k.\n\nA positive integer x is called comp...
valid-binary-strings-with-cost-limit
valid-binary-strings-with-cost-limit__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 two integers n and k.\n\nThe cost of a binary string s is de...
maximum-sum-of-m-non-overlapping-subarrays-i
maximum-sum-of-m-non-overlapping-subarrays-i__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums of length n, and three integers m, l, ...
maximum-sum-of-m-non-overlapping-subarrays-ii
maximum-sum-of-m-non-overlapping-subarrays-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 given an integer array nums of length n, and three integers m, l, ...
minimum-cost-to-split-into-ones-ii
minimum-cost-to-split-into-ones-ii__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 n.\n\nIn one operation, you may split an integer ...
check-good-integer
check-good-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\nYou are given a positive integer n.\n\nLet digitSum be the sum of the digi...
frequency-balance-subarray
frequency-balance-subarray__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.\n\nDefine a frequency balance ...
maximize-sum-of-device-ratings
maximize-sum-of-device-ratings__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 2D integer array units of size m × n where units[i][...
maximum-subarray-sum-after-at-most-k-swaps
maximum-subarray-sum-after-at-most-k-swaps__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 are given an integer array nums and an integer k.\n\nYou are allowed t...
create-grid-with-exactly-one-path
create-grid-with-exactly-one-path__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 are given two integers m and n, representing the number of rows and co...
minimum-lights-to-illuminate-a-road
minimum-lights-to-illuminate-a-road__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 are given an integer array lights of length n, representing positions ...
finish-time-of-tasks-i
finish-time-of-tasks-i__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 integer n representing the number of tasks in a project, ...
count-good-integers-in-a-range
count-good-integers-in-a-range__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 are given three integers l, r and k.\n\nA number is considered good if...
finish-time-of-tasks-ii
finish-time-of-tasks-ii__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 are given an integer n representing the number of tasks in a project, ...
maximum-manhattan-distance-after-all-moves
maximum-manhattan-distance-after-all-moves__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 string moves consisting of the characters 'U', 'D', 'L', '...
valid-subarrays-with-matching-sum-digits-i
valid-subarrays-with-matching-sum-digits-i__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 an integer array nums and an integer digit x.\n\nA subarray ...
shortest-path-with-at-most-k-consecutive-identical-characters
shortest-path-with-at-most-k-consecutive-identical-characters__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 n representing the number of nodes in a directed ...
maximum-total-value
maximum-total-value__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 value and decay, and an integer m.\n\n\tv...
valid-subarrays-with-matching-sum-digits-ii
valid-subarrays-with-matching-sum-digits-ii__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 an integer array nums and an integer digit x.\n\nA subarray ...
distinct-gate-paths-to-lca
distinct-gate-paths-to-lca__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 undirected tree rooted at node 0 with n nodes numbered fr...
maximum-total-sum-of-k-selected-elements
maximum-total-sum-of-k-selected-elements__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 two integers k and mul.\n\nSelect ...
filter-occupied-intervals
filter-occupied-intervals__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 2D integer array occupiedIntervals, where occupiedInterval...
maximum-subarray-sum-after-multiplier
maximum-subarray-sum-after-multiplier__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums and a positive integer k.\n\nYou must ...
minimum-time-to-reach-target-with-limited-power
minimum-time-to-reach-target-with-limited-power__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 directed weighted graph with n nodes labeled from 0 to n -...