slug
stringlengths
3
79
solution_id
stringlengths
13
89
primary_algorithm
stringclasses
22 values
verified
null
messages
listlengths
3
3
kids-with-the-greatest-number-of-candies
kids-with-the-greatest-number-of-candies__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\nThere are n kids with candies. You are given an integer array candies, whe...
max-difference-you-can-get-from-changing-an-integer
max-difference-you-can-get-from-changing-an-integer__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 num. You will apply the following steps to num tw...
check-if-a-string-can-break-another-string
check-if-a-string-can-break-another-string__01__java
Greedy
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven two strings: s1 and s2 with the same size, check if some permutation...
number-of-ways-to-wear-different-hats-to-each-other
number-of-ways-to-wear-different-hats-to-each-other__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n people and 40 types of hats labeled from 1 to 40.\n\nGiven a 2...
destination-city
destination-city__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 the array paths, where paths[i] = [cityAi, cityBi] means the...
check-if-all-1s-are-at-least-length-k-places-away
check-if-all-1s-are-at-least-length-k-places-away__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 binary array nums and an integer k, return true if all 1's are at...
longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit
longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit__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 array of integers nums and an integer limit, return the size of t...
longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit
longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit__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 an array of integers nums and an integer limit, return the size of t...
longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit
longest-continuous-subarray-with-absolute-diff-less-than-or-equal-to-limit__03__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 array of integers nums and an integer limit, return the size of t...
find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows
find-the-kth-smallest-sum-of-a-matrix-with-sorted-rows__01__java
Binary Search
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an m x n matrix mat that has its rows sorted in non-decreasi...
build-an-array-with-stack-operations
build-an-array-with-stack-operations__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 target and an integer n.\n\nYou have an emp...
count-triplets-that-can-form-two-arrays-of-equal-xor
count-triplets-that-can-form-two-arrays-of-equal-xor__01__java
Bit Manipulation
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an array of integers arr.\n\nWe want to select three indices i, j an...
minimum-time-to-collect-all-apples-in-a-tree
minimum-time-to-collect-all-apples-in-a-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 an undirected tree consisting of n vertices numbered from 0 to n-1, ...
number-of-ways-of-cutting-a-pizza
number-of-ways-of-cutting-a-pizza__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 rectangular pizza represented as a rows x cols matrix containing t...
consecutive-characters
consecutive-characters__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\nThe power of the string is the maximum length of a non-empty substring tha...
simplified-fractions
simplified-fractions__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an integer n, return a list of all simplified fractions between 0 an...
count-good-nodes-in-binary-tree
count-good-nodes-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 a binary tree root, a node X in the tree is named good if in the pat...
form-largest-integer-with-digits-that-add-up-to-target
form-largest-integer-with-digits-that-add-up-to-target__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 cost and an integer target, return the maximum ...
number-of-students-doing-homework-at-a-given-time
number-of-students-doing-homework-at-a-given-time__01__java
Array
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven two integer arrays startTime and endTime and given an integer queryT...
rearrange-words-in-a-sentence
rearrange-words-in-a-sentence__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 a sentence text (A sentence is a string of space-separated words) in...
people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list
people-whose-list-of-favorite-companies-is-not-a-subset-of-another-list__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 the array favoriteCompanies where favoriteCompanies[i] is the list o...
maximum-number-of-darts-inside-of-a-circular-dartboard
maximum-number-of-darts-inside-of-a-circular-dartboard__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nAlice is throwing n darts on a very large wall. You are given an array dar...
check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence
check-if-a-word-occurs-as-a-prefix-of-any-word-in-a-sentence__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 sentence that consists of some words separated by a single space, ...
maximum-number-of-vowels-in-a-substring-of-given-length
maximum-number-of-vowels-in-a-substring-of-given-length__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 string s and an integer k, return the maximum number of vowel lett...
pseudo-palindromic-paths-in-a-binary-tree
pseudo-palindromic-paths-in-a-binary-tree__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a binary tree where node values are digits from 1 to 9. A path in th...
max-dot-product-of-two-subsequences
max-dot-product-of-two-subsequences__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 two arrays nums1 and nums2.\n\nReturn the maximum dot product betwee...
make-two-arrays-equal-by-reversing-subarrays
make-two-arrays-equal-by-reversing-subarrays__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 integer arrays of equal length target and arr. In one st...
make-two-arrays-equal-by-reversing-subarrays
make-two-arrays-equal-by-reversing-subarrays__02__java
Sorting
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two integer arrays of equal length target and arr. In one st...
check-if-a-string-contains-all-binary-codes-of-size-k
check-if-a-string-contains-all-binary-codes-of-size-k__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a binary string s and an integer k, return true if every binary code...
check-if-a-string-contains-all-binary-codes-of-size-k
check-if-a-string-contains-all-binary-codes-of-size-k__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 string s and an integer k, return true if every binary code...
course-schedule-iv
course-schedule-iv__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 a total of numCourses courses you have to take, labeled from 0 t...
course-schedule-iv
course-schedule-iv__02__java
Sorting
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are a total of numCourses courses you have to take, labeled from 0 t...
cherry-pickup-ii
cherry-pickup-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 a rows x cols matrix grid representing a field of cherries w...
cherry-pickup-ii
cherry-pickup-ii__02__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given a rows x cols matrix grid representing a field of cherries w...
maximum-product-of-two-elements-in-an-array
maximum-product-of-two-elements-in-an-array__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 the array of integers nums, you will choose two different indices i ...
maximum-product-of-two-elements-in-an-array
maximum-product-of-two-elements-in-an-array__02__java
Sorting
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the array of integers nums, you will choose two different indices i ...
maximum-product-of-two-elements-in-an-array
maximum-product-of-two-elements-in-an-array__03__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 the array of integers nums, you will choose two different indices i ...
maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts
maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts__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 rectangular cake of size h x w and two arrays of integers ...
reorder-routes-to-make-all-paths-lead-to-the-city-zero
reorder-routes-to-make-all-paths-lead-to-the-city-zero__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 cities numbered from 0 to n - 1 and n - 1 roads such that ther...
probability-of-a-two-boxes-having-the-same-number-of-distinct-balls
probability-of-a-two-boxes-having-the-same-number-of-distinct-balls__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 2n balls of k distinct colors. You will be given an integer array ba...
find-all-the-lonely-nodes
find-all-the-lonely-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\nIn a binary tree, a lonely node is a node that is the only child of its pa...
shuffle-the-array
shuffle-the-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 the array nums consisting of 2n elements in the form [x1,x2,...,xn,y...
the-k-strongest-values-in-an-array
the-k-strongest-values-in-an-array__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 arr and an integer k.\n\nA value arr[i] is said...
design-browser-history
design-browser-history__01__java
Linked List
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou have a browser of one tab where you start on the homepage and you can ...
paint-house-iii
paint-house-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\nThere is a row of m houses in a small city, each house must be painted wit...
delete-n-nodes-after-m-nodes-of-a-linked-list
delete-n-nodes-after-m-nodes-of-a-linked-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\nYou are given the head of a linked list and two integers m and n.\n\nTrave...
final-prices-with-a-special-discount-in-a-shop
final-prices-with-a-special-discount-in-a-shop__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 prices where prices[i] is the price of the ...
subrectangle-queries
subrectangle-queries__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\nImplement the class SubrectangleQueries which receives a rows x cols recta...
find-two-non-overlapping-sub-arrays-each-with-target-sum
find-two-non-overlapping-sub-arrays-each-with-target-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\nYou are given an array of integers arr and an integer target.\n\nYou have ...
allocate-mailboxes
allocate-mailboxes__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 the array houses where houses[i] is the location of the ith house al...
running-sum-of-1d-array
running-sum-of-1d-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 array nums. We define a running sum of an array as runningSum[i] ...
least-number-of-unique-integers-after-k-removals
least-number-of-unique-integers-after-k-removals__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 arr and an integer k. Find the least number of ...
minimum-number-of-days-to-make-m-bouquets
minimum-number-of-days-to-make-m-bouquets__01__java
Binary Search
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array bloomDay, an integer m and an integer k.\n\...
kth-ancestor-of-a-tree-node
kth-ancestor-of-a-tree-node__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 tree with n nodes numbered from 0 to n - 1 in the form of ...
clone-binary-tree-with-random-pointer
clone-binary-tree-with-random-pointer__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nA binary tree is given such that each node contains an additional random p...
xor-operation-in-an-array
xor-operation-in-an-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\nYou are given an integer n and an integer start.\n\nDefine an array nums w...
making-file-names-unique
making-file-names-unique__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 strings names of size n. You will create n folders in yo...
avoid-flood-in-the-city
avoid-flood-in-the-city__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\nYour country has 109 lakes. Initially, all the lakes are empty, but when i...
find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree
find-critical-and-pseudo-critical-edges-in-minimum-spanning-tree__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\nGiven a weighted undirected connected graph with n vertices numbered from ...
clone-n-ary-tree
clone-n-ary-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 root of an N-ary tree, return a deep copy (clone) of the tree.\n\n...
average-salary-excluding-the-minimum-and-maximum-salary
average-salary-excluding-the-minimum-and-maximum-salary__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 of unique integers salary where salary[i] is the sa...
the-kth-factor-of-n
the-kth-factor-of-n__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 positive integers n and k. A factor of an integer n is d...
the-kth-factor-of-n
the-kth-factor-of-n__02__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two positive integers n and k. A factor of an integer n is d...
longest-subarray-of-1s-after-deleting-one-element
longest-subarray-of-1s-after-deleting-one-element__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 binary array nums, you should delete one element from it.\n\nRetur...
longest-subarray-of-1s-after-deleting-one-element
longest-subarray-of-1s-after-deleting-one-element__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 binary array nums, you should delete one element from it.\n\nRetur...
longest-subarray-of-1s-after-deleting-one-element
longest-subarray-of-1s-after-deleting-one-element__03__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 binary array nums, you should delete one element from it.\n\nRetur...
parallel-courses-ii
parallel-courses-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 n, which indicates that there are n courses label...
path-crossing
path-crossing__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 path, where path[i] = 'N', 'S', 'E' or 'W', each representi...
check-if-array-pairs-are-divisible-by-k
check-if-array-pairs-are-divisible-by-k__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an array of integers arr of even length n and an integer k.\n\nWe wa...
number-of-subsequences-that-satisfy-the-given-sum-condition
number-of-subsequences-that-satisfy-the-given-sum-condition__01__java
Binary Search
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array of integers nums and an integer target.\n\nReturn t...
max-value-of-equation
max-value-of-equation__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 array points containing the coordinates of points on a 2D...
max-value-of-equation
max-value-of-equation__02__java
Sliding Window
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array points containing the coordinates of points on a 2D...
design-a-file-sharing-system
design-a-file-sharing-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\nWe will use a file-sharing system to share a very large file which consist...
can-make-arithmetic-progression-from-sequence
can-make-arithmetic-progression-from-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\nA sequence of numbers is called an arithmetic progression if the differenc...
can-make-arithmetic-progression-from-sequence
can-make-arithmetic-progression-from-sequence__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\nA sequence of numbers is called an arithmetic progression if the differenc...
last-moment-before-all-ants-fall-out-of-a-plank
last-moment-before-all-ants-fall-out-of-a-plank__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\nWe have a wooden plank of the length n units. Some ants are walking on the...
count-submatrices-with-all-ones
count-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 an m x n binary matrix mat, return the number of submatrices that ha...
minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits
minimum-possible-integer-after-at-most-k-adjacent-swaps-on-digits__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 num representing the digits of a very large integer...
find-root-of-n-ary-tree
find-root-of-n-ary-tree__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given all the nodes of an N-ary tree as an array of Node objects, ...
reformat-date
reformat-date__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 date string in the form Day Month Year, where:\n\n\tDay is in the ...
range-sum-of-sorted-subarray-sums
range-sum-of-sorted-subarray-sums__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 the array nums consisting of n positive integers. You comput...
minimum-difference-between-largest-and-smallest-value-in-three-moves
minimum-difference-between-largest-and-smallest-value-in-three-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 an integer array nums.\n\nIn one move, you can choose one el...
stone-game-iv
stone-game-iv__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\nAlice and Bob take turns playing a game, with Alice starting first.\n\nIni...
stone-game-iv
stone-game-iv__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 take turns playing a game, with Alice starting first.\n\nIni...
number-of-good-pairs
number-of-good-pairs__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 of integers nums, return the number of good pairs.\n\nA pai...
number-of-substrings-with-only-1s
number-of-substrings-with-only-1s__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 binary string s, return the number of substrings with all characte...
path-with-maximum-probability
path-with-maximum-probability__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\nYou are given an undirected weighted graph of n nodes (0-indexed), represe...
best-position-for-a-service-centre
best-position-for-a-service-centre__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 delivery company wants to build a new service center in a new city. The ...
move-sub-tree-of-n-ary-tree
move-sub-tree-of-n-ary-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 an N-ary tree of unique values, and two nodes of the tre...
water-bottles
water-bottles__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are numBottles water bottles that are initially full of water. You c...
number-of-nodes-in-the-sub-tree-with-the-same-label
number-of-nodes-in-the-sub-tree-with-the-same-label__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 tree (i.e. a connected, undirected graph that has no cycle...
maximum-number-of-non-overlapping-substrings
maximum-number-of-non-overlapping-substrings__01__java
Greedy
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s of lowercase letters, you need to find the maximum number...
find-a-value-of-a-mysterious-function-closest-to-target
find-a-value-of-a-mysterious-function-closest-to-target__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\nWinston was given the above mysterious function func. He has an integer ar...
diameter-of-n-ary-tree
diameter-of-n-ary-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 root of an N-ary tree, you need to compute the length of the diame...
diameter-of-n-ary-tree
diameter-of-n-ary-tree__02__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a root of an N-ary tree, you need to compute the length of the diame...
count-odd-numbers-in-an-interval-range
count-odd-numbers-in-an-interval-range__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 non-negative integers low and high. Return the count of odd numb...
number-of-sub-arrays-with-odd-sum
number-of-sub-arrays-with-odd-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 array of integers arr, return the number of subarrays with an odd...
number-of-good-ways-to-split-a-string
number-of-good-ways-to-split-a-string__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.\n\nA split is called good if you can split s int...
minimum-number-of-increments-on-subarrays-to-form-a-target-array
minimum-number-of-increments-on-subarrays-to-form-a-target-array__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 target. You have an integer array initial o...
shuffle-string
shuffle-string__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 and an integer array indices of the same length. ...