slug
stringlengths
3
79
solution_id
stringlengths
13
89
primary_algorithm
stringclasses
22 values
verified
null
messages
listlengths
3
3
replace-the-substring-for-balanced-string
replace-the-substring-for-balanced-string__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a string s of length n containing only four kinds of charact...
maximum-profit-in-job-scheduling
maximum-profit-in-job-scheduling__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\nWe have n jobs, where every job is scheduled to be done from startTime[i] ...
maximum-profit-in-job-scheduling
maximum-profit-in-job-scheduling__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\nWe have n jobs, where every job is scheduled to be done from startTime[i] ...
web-crawler
web-crawler__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a url startUrl and an interface HtmlParser, implement a web crawler ...
find-positive-integer-solution-for-a-given-equation
find-positive-integer-solution-for-a-given-equation__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 a callable function f(x, y) with a hidden formula and a value z, rev...
find-positive-integer-solution-for-a-given-equation
find-positive-integer-solution-for-a-given-equation__02__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a callable function f(x, y) with a hidden formula and a value z, rev...
circular-permutation-in-binary-representation
circular-permutation-in-binary-representation__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 2 integers n and start. Your task is return any permutation p of (0,...
circular-permutation-in-binary-representation
circular-permutation-in-binary-representation__02__java
Backtracking
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven 2 integers n and start. Your task is return any permutation p of (0,...
maximum-length-of-a-concatenated-string-with-unique-characters
maximum-length-of-a-concatenated-string-with-unique-characters__01__java
Bit Manipulation
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array of strings arr. A string s is formed by the concate...
tiling-a-rectangle-with-the-fewest-squares
tiling-a-rectangle-with-the-fewest-squares__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 rectangle of size n x m, return the minimum number of integer-side...
tiling-a-rectangle-with-the-fewest-squares
tiling-a-rectangle-with-the-fewest-squares__02__java
Backtracking
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a rectangle of size n x m, return the minimum number of integer-side...
web-crawler-multithreaded
web-crawler-multithreaded__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a URL startUrl and an interface HtmlParser, implement a Multi-thread...
array-transformation
array-transformation__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 initial array arr, every day you produce a new array using the ar...
design-a-leaderboard
design-a-leaderboard__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\nDesign a Leaderboard class, which has 3 functions:\n\n\taddScore(playerId,...
tree-diameter
tree-diameter__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\nThe diameter of a tree is the number of edges in the longest path in that ...
palindrome-removal
palindrome-removal__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 arr.\n\nIn one move, you can select a palin...
minimum-swaps-to-make-strings-equal
minimum-swaps-to-make-strings-equal__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 strings s1 and s2 of equal length consisting of letters ...
count-number-of-nice-subarrays
count-number-of-nice-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 array of integers nums and an integer k. A continuous subarray is...
minimum-remove-to-make-valid-parentheses
minimum-remove-to-make-valid-parentheses__01__java
String
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s of '(' , ')' and lowercase English characters.\n\nYour ta...
check-if-it-is-a-good-array
check-if-it-is-a-good-array__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 array nums of positive integers. Your task is to select some subs...
cells-with-odd-values-in-a-matrix
cells-with-odd-values-in-a-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\nThere is an m x n matrix that is initialized to all 0's. There is also a 2...
cells-with-odd-values-in-a-matrix
cells-with-odd-values-in-a-matrix__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\nThere is an m x n matrix that is initialized to all 0's. There is also a 2...
cells-with-odd-values-in-a-matrix
cells-with-odd-values-in-a-matrix__03__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 an m x n matrix that is initialized to all 0's. There is also a 2...
reconstruct-a-2-row-binary-matrix
reconstruct-a-2-row-binary-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\nGiven the following details of a matrix with n columns and 2 rows :\n\n\tT...
number-of-closed-islands
number-of-closed-islands__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a 2D grid consists of 0s (land) and 1s (water). An island is a maxi...
number-of-closed-islands
number-of-closed-islands__02__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a 2D grid consists of 0s (land) and 1s (water). An island is a maxi...
maximum-score-words-formed-by-letters
maximum-score-words-formed-by-letters__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 list of words, list of single letters (might be repeating) and sc...
encode-number
encode-number__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 non-negative integer num, Return its encoding string.\n\nThe encod...
smallest-common-region
smallest-common-region__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 some lists of regions where the first region of each list di...
synonymous-sentences
synonymous-sentences__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 list of equivalent string pairs synonyms where synonyms[i]...
handshakes-that-dont-cross
handshakes-that-dont-cross__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 even number of people numPeople that stand around a circl...
shift-2d-grid
shift-2d-grid__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 grid of size m x n and an integer k. You need to shift the grid...
find-elements-in-a-contaminated-binary-tree
find-elements-in-a-contaminated-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 a binary tree with the following rules:\n\n\troot.val == 0\n\tFor an...
greatest-sum-divisible-by-three
greatest-sum-divisible-by-three__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 maximum possible sum of elements o...
greatest-sum-divisible-by-three
greatest-sum-divisible-by-three__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 maximum possible sum of elements o...
minimum-moves-to-move-a-box-to-their-target-location
minimum-moves-to-move-a-box-to-their-target-location__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 storekeeper is a game in which the player pushes boxes around in a wareh...
print-immutable-linked-list-in-reverse
print-immutable-linked-list-in-reverse__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an immutable linked list, print out all values of each node ...
minimum-time-visiting-all-points
minimum-time-visiting-all-points__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nOn a 2D plane, there are n points with integer coordinates points[i] = [xi...
count-servers-that-communicate
count-servers-that-communicate__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 map of a server center, represented as a m * n integer mat...
search-suggestions-system
search-suggestions-system__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 products and a string searchWord.\n\nDes...
number-of-ways-to-stay-in-the-same-place-after-some-steps
number-of-ways-to-stay-in-the-same-place-after-some-steps__01__java
Memoization
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou have a pointer at index 0 in an array of size arrLen. At each step, yo...
hexspeak
hexspeak__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 decimal number can be converted to its Hexspeak representation by first ...
remove-interval
remove-interval__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\nA set of real numbers can be represented as the union of several disjoint ...
delete-tree-nodes
delete-tree-nodes__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nA tree rooted at node 0 is given as follows:\n\n\tThe number of nodes is n...
number-of-ships-in-a-rectangle
number-of-ships-in-a-rectangle__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\n(This problem is an interactive problem.)\n\nEach ship is located at an in...
find-winner-on-a-tic-tac-toe-game
find-winner-on-a-tic-tac-toe-game__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nTic-tac-toe is played by two players A and B on a 3 x 3 grid. The rules of...
number-of-burgers-with-no-waste-of-ingredients
number-of-burgers-with-no-waste-of-ingredients__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven two integers tomatoSlices and cheeseSlices. The ingredients of diffe...
count-square-submatrices-with-all-ones
count-square-submatrices-with-all-ones__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 m * n matrix of ones and zeros, return how many square submatrices...
palindrome-partitioning-iii
palindrome-partitioning-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 a string s containing lowercase letters and an integer k. Yo...
traffic-light-controlled-intersection
traffic-light-controlled-intersection__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 intersection of two roads. First road is road A where cars tra...
subtract-the-product-and-sum-of-digits-of-an-integer
subtract-the-product-and-sum-of-digits-of-an-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\nGiven an integer number n, return the difference between the product of it...
group-the-people-given-the-group-size-they-belong-to
group-the-people-given-the-group-size-they-belong-to__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n people that are split into some unknown number of groups. Each...
find-the-smallest-divisor-given-a-threshold
find-the-smallest-divisor-given-a-threshold__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 and an integer threshold, we will choose a...
minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix
minimum-number-of-flips-to-convert-binary-matrix-to-zero-matrix__01__java
BFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a m x n binary matrix mat. In one step, you can choose one cell and ...
iterator-for-combination
iterator-for-combination__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\nDesign the CombinationIterator class:\n\n\tCombinationIterator(string char...
iterator-for-combination
iterator-for-combination__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\nDesign the CombinationIterator class:\n\n\tCombinationIterator(string char...
element-appearing-more-than-25-in-sorted-array
element-appearing-more-than-25-in-sorted-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\nGiven an integer array sorted in non-decreasing order, there is exactly on...
remove-covered-intervals
remove-covered-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\nGiven an array intervals where intervals[i] = [li, ri] represent the inter...
minimum-falling-path-sum-ii
minimum-falling-path-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\nGiven an n x n integer matrix grid, return the minimum sum of a falling pa...
convert-binary-number-in-a-linked-list-to-integer
convert-binary-number-in-a-linked-list-to-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\nGiven head which is a reference node to a singly-linked list. The value of...
sequential-digits
sequential-digits__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\nAn integer has sequential digits if and only if each digit in the number i...
maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold
maximum-side-length-of-a-square-with-sum-less-than-or-equal-to-threshold__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 a m x n matrix mat and an integer threshold, return the maximum side...
shortest-path-in-a-grid-with-obstacles-elimination
shortest-path-in-a-grid-with-obstacles-elimination__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 integer matrix grid where each cell is either 0 (em...
find-numbers-with-even-number-of-digits
find-numbers-with-even-number-of-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 array nums of integers, return how many of them contain an even n...
divide-array-in-sets-of-k-consecutive-numbers
divide-array-in-sets-of-k-consecutive-numbers__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 nums and a positive integer k, check whether it...
divide-array-in-sets-of-k-consecutive-numbers
divide-array-in-sets-of-k-consecutive-numbers__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\nGiven an array of integers nums and a positive integer k, check whether it...
maximum-number-of-occurrences-of-a-substring
maximum-number-of-occurrences-of-a-substring__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s, return the maximum number of occurrences of any substrin...
maximum-number-of-occurrences-of-a-substring
maximum-number-of-occurrences-of-a-substring__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 string s, return the maximum number of occurrences of any substrin...
maximum-candies-you-can-get-from-boxes
maximum-candies-you-can-get-from-boxes__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 have n boxes labeled from 0 to n - 1. You are given four arrays: statu...
replace-elements-with-greatest-element-on-right-side
replace-elements-with-greatest-element-on-right-side__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 arr, replace every element in that array with the greatest ...
sum-of-mutated-array-closest-to-target
sum-of-mutated-array-closest-to-target__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 arr and a target value target, return the integer v...
number-of-paths-with-max-score
number-of-paths-with-max-score__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 square board of characters. You can move on the board star...
deepest-leaves-sum
deepest-leaves-sum__01__java
BFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, return the sum of values of its deepest l...
deepest-leaves-sum
deepest-leaves-sum__02__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, return the sum of values of its deepest l...
find-n-unique-integers-sum-up-to-zero
find-n-unique-integers-sum-up-to-zero__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 any array containing n unique integers such tha...
find-n-unique-integers-sum-up-to-zero
find-n-unique-integers-sum-up-to-zero__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 integer n, return any array containing n unique integers such tha...
all-elements-in-two-binary-search-trees
all-elements-in-two-binary-search-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\nGiven two binary search trees root1 and root2, return a list containing al...
jump-game-iii
jump-game-iii__01__java
BFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an array of non-negative integers arr, you are initially positioned ...
verbal-arithmetic-puzzle
verbal-arithmetic-puzzle__01__java
Backtracking
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an equation, represented by words on the left side and the result on...
decrypt-string-from-alphabet-to-integer-mapping
decrypt-string-from-alphabet-to-integer-mapping__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 formed by digits and '#'. We want to map s to Eng...
xor-queries-of-a-subarray
xor-queries-of-a-subarray__01__java
Bit Manipulation
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array arr of positive integers. You are also given the ar...
get-watched-videos-by-your-friends
get-watched-videos-by-your-friends__01__java
BFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n people, each person has a unique id between 0 and n-1. Given t...
minimum-insertion-steps-to-make-a-string-palindrome
minimum-insertion-steps-to-make-a-string-palindrome__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. In one step you can insert any character at any index of...
minimum-insertion-steps-to-make-a-string-palindrome
minimum-insertion-steps-to-make-a-string-palindrome__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. In one step you can insert any character at any index of...
minimum-insertion-steps-to-make-a-string-palindrome
minimum-insertion-steps-to-make-a-string-palindrome__03__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s. In one step you can insert any character at any index of...
decompress-run-length-encoded-list
decompress-run-length-encoded-list__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nWe are given a list nums of integers representing a list compressed with r...
matrix-block-sum
matrix-block-sum__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 m x n matrix mat and an integer k, return a matrix answer where ea...
sum-of-nodes-with-even-valued-grandparent
sum-of-nodes-with-even-valued-grandparent__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 sum of values of nodes with an...
distinct-echo-substrings
distinct-echo-substrings__01__java
Trie
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nReturn the number of distinct non-empty substrings of text that can be wri...
convert-integer-to-the-sum-of-two-no-zero-integers
convert-integer-to-the-sum-of-two-no-zero-integers__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\nNo-Zero integer is a positive integer that does not contain any 0 in its d...
convert-integer-to-the-sum-of-two-no-zero-integers
convert-integer-to-the-sum-of-two-no-zero-integers__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\nNo-Zero integer is a positive integer that does not contain any 0 in its d...
minimum-flips-to-make-a-or-b-equal-to-c
minimum-flips-to-make-a-or-b-equal-to-c__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 3 positives numbers a, b and c. Return the minimum flips required in...
number-of-operations-to-make-network-connected
number-of-operations-to-make-network-connected__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n computers numbered from 0 to n - 1 connected by ethernet cable...
minimum-distance-to-type-a-word-using-two-fingers
minimum-distance-to-type-a-word-using-two-fingers__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou have a keyboard layout as shown above in the X-Y plane, where each Eng...
maximum-69-number
maximum-69-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 a positive integer num consisting only of digits 6 and 9.\n\...
print-words-vertically
print-words-vertically__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 string s. Return all the words vertically in the same order in whi...
delete-leaves-with-a-given-value
delete-leaves-with-a-given-value__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a binary tree root and an integer target, delete all the leaf nodes ...
minimum-number-of-taps-to-open-to-water-a-garden
minimum-number-of-taps-to-open-to-water-a-garden__01__java
Greedy
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is a one-dimensional garden on the x-axis. The garden starts at the ...
break-a-palindrome
break-a-palindrome__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 palindromic string of lowercase English letters palindrome, replac...
sort-the-matrix-diagonally
sort-the-matrix-diagonally__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 matrix diagonal is a diagonal line of cells starting from some cell in e...