slug
stringlengths
3
79
solution_id
stringlengths
13
89
primary_algorithm
stringclasses
22 values
verified
null
messages
listlengths
3
3
count-good-meals
count-good-meals__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nA good meal is a meal that contains exactly two different food items with ...
count-good-meals
count-good-meals__02__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nA good meal is a meal that contains exactly two different food items with ...
ways-to-split-array-into-three-subarrays
ways-to-split-array-into-three-subarrays__01__java
Binary Search
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nA split of an integer array is good if:\n\n\tThe array is split into three...
minimum-operations-to-make-a-subsequence
minimum-operations-to-make-a-subsequence__01__java
Greedy
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array target that consists of distinct integers and anoth...
sum-of-special-evenly-spaced-elements-in-array
sum-of-special-evenly-spaced-elements-in-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 a 0-indexed integer array nums consisting of n non-negative ...
calculate-money-in-leetcode-bank
calculate-money-in-leetcode-bank__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\nHercy wants to save money for his first car. He puts money in the Leetcode...
maximum-score-from-removing-substrings
maximum-score-from-removing-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\nYou are given a string s and two integers x and y. You can perform two typ...
construct-the-lexicographically-largest-valid-sequence
construct-the-lexicographically-largest-valid-sequence__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 integer n, find a sequence with elements in the range [1, n] that...
number-of-ways-to-reconstruct-a-tree
number-of-ways-to-reconstruct-a-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\nYou are given an array pairs, where pairs[i] = [xi, yi], and:\n\n\tThere a...
decode-xored-array
decode-xored-array__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\nThere is a hidden integer array arr that consists of n non-negative intege...
swapping-nodes-in-a-linked-list
swapping-nodes-in-a-linked-list__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given the head of a linked list, and an integer k.\n\nReturn the h...
minimize-hamming-distance-after-swap-operations
minimize-hamming-distance-after-swap-operations__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two integer arrays, source and target, both of length n. You...
find-minimum-time-to-finish-all-jobs
find-minimum-time-to-finish-all-jobs__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 jobs, where jobs[i] is the amount of time i...
checking-existence-of-edge-length-limited-paths-ii
checking-existence-of-edge-length-limited-paths-ii__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nAn undirected graph of n nodes is defined by edgeList, where edgeList[i] =...
number-of-rectangles-that-can-form-the-largest-square
number-of-rectangles-that-can-form-the-largest-square__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 array rectangles where rectangles[i] = [li, wi] represent...
tuple-with-same-product
tuple-with-same-product__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 nums of distinct positive integers, return the number of tu...
largest-submatrix-with-rearrangements
largest-submatrix-with-rearrangements__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 binary matrix matrix of size m x n, and you are allowed to...
cat-and-mouse-ii
cat-and-mouse-ii__01__java
Sorting
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nA game is played by a cat and a mouse named Cat and Mouse.\n\nThe environm...
shortest-path-to-get-food
shortest-path-to-get-food__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 starving and you want to eat food as quickly as possible. You want...
find-the-highest-altitude
find-the-highest-altitude__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 is a biker going on a road trip. The road trip consists of n + 1 poi...
minimum-number-of-people-to-teach
minimum-number-of-people-to-teach__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 social network consisting of m users and some friendships between use...
decode-xored-permutation
decode-xored-permutation__01__java
Bit Manipulation
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is an integer array perm that is a permutation of the first n positi...
count-ways-to-make-array-with-product
count-ways-to-make-array-with-product__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 2D integer array, queries. For each queries[i], where quer...
latest-time-by-replacing-hidden-digits
latest-time-by-replacing-hidden-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 time in the form of hh:mm, where some of the digit...
change-minimum-characters-to-satisfy-one-of-three-conditions
change-minimum-characters-to-satisfy-one-of-three-conditions__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two strings a and b that consist of lowercase letters. In on...
find-kth-largest-xor-coordinate-value
find-kth-largest-xor-coordinate-value__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 matrix of size m x n, consisting of non-negative intege...
building-boxes
building-boxes__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 have a cubic storeroom where the width, length, and height of the room...
find-distance-in-a-binary-tree
find-distance-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 the root of a binary tree and two integers p and q, return the dista...
maximum-number-of-balls-in-a-box
maximum-number-of-balls-in-a-box__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 working in a ball factory where you have n balls numbered from low...
restore-the-array-from-adjacent-pairs
restore-the-array-from-adjacent-pairs__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is an integer array nums that consists of n unique elements, but you...
restore-the-array-from-adjacent-pairs
restore-the-array-from-adjacent-pairs__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\nThere is an integer array nums that consists of n unique elements, but you...
can-you-eat-your-favorite-candy-on-your-favorite-day
can-you-eat-your-favorite-candy-on-your-favorite-day__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 a (0-indexed) array of positive integers candiesCount where ...
palindrome-partitioning-iv
palindrome-partitioning-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\nGiven a string s, return true if it is possible to split the string s into...
maximum-subarray-sum-after-one-operation
maximum-subarray-sum-after-one-operation__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. You must perform exactly one operatio...
sum-of-unique-elements
sum-of-unique-elements__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. The unique elements of an array are t...
sum-of-unique-elements
sum-of-unique-elements__02__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums. The unique elements of an array are t...
maximum-absolute-sum-of-any-subarray
maximum-absolute-sum-of-any-subarray__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums. The absolute sum of a subarray [numsl...
minimum-length-of-string-after-deleting-similar-ends
minimum-length-of-string-after-deleting-similar-ends__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s consisting only of characters 'a', 'b', and 'c'. You are ...
maximum-number-of-events-that-can-be-attended-ii
maximum-number-of-events-that-can-be-attended-ii__01__java
Memoization
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array of events where events[i] = [startDayi, endDayi, va...
maximum-number-of-events-that-can-be-attended-ii
maximum-number-of-events-that-can-be-attended-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 an array of events where events[i] = [startDayi, endDayi, va...
check-if-array-is-sorted-and-rotated
check-if-array-is-sorted-and-rotated__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, return true if the array was originally sorted in non...
maximum-score-from-removing-stones
maximum-score-from-removing-stones__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 playing a solitaire game with three piles of stones of sizes a​​​​...
maximum-score-from-removing-stones
maximum-score-from-removing-stones__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\nYou are playing a solitaire game with three piles of stones of sizes a​​​​...
largest-merge-of-two-strings
largest-merge-of-two-strings__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 word1 and word2. You want to construct a string ...
closest-subsequence-sum
closest-subsequence-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 integer array nums and an integer goal.\n\nYou want to ch...
closest-subsequence-sum
closest-subsequence-sum__02__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array nums and an integer goal.\n\nYou want to ch...
design-most-recently-used-queue
design-most-recently-used-queue__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\nDesign a queue-like data structure that moves the most recently used eleme...
minimum-changes-to-make-alternating-binary-string
minimum-changes-to-make-alternating-binary-string__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 string s consisting only of the characters '0' and '1'. In...
count-number-of-homogenous-substrings
count-number-of-homogenous-substrings__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 string s, return the number of homogenous substrings of s. Since t...
count-number-of-homogenous-substrings
count-number-of-homogenous-substrings__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 a string s, return the number of homogenous substrings of s. Since t...
minimum-limit-of-balls-in-a-bag
minimum-limit-of-balls-in-a-bag__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 nums where the ith bag contains nums[i] bal...
minimum-degree-of-a-connected-trio-in-a-graph
minimum-degree-of-a-connected-trio-in-a-graph__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 undirected graph. You are given an integer n which is the...
buildings-with-an-ocean-view
buildings-with-an-ocean-view__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 buildings in a line. You are given an integer array heights of...
longest-nice-substring
longest-nice-substring__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\nA string s is nice if, for every letter of the alphabet that s contains, i...
longest-nice-substring
longest-nice-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\nA string s is nice if, for every letter of the alphabet that s contains, i...
form-array-by-concatenating-subarrays-of-another-array
form-array-by-concatenating-subarrays-of-another-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 a 2D integer array groups of length n. You are also given an...
map-of-highest-peak
map-of-highest-peak__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 integer matrix isWater of size m x n that represents a ma...
map-of-highest-peak
map-of-highest-peak__02__java
BFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer matrix isWater of size m x n that represents a ma...
tree-of-coprimes
tree-of-coprimes__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\nThere is a tree (i.e., a connected, undirected graph that has no cycles) c...
merge-strings-alternately
merge-strings-alternately__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 strings word1 and word2. Merge the strings by adding let...
minimum-number-of-operations-to-move-all-balls-to-each-box
minimum-number-of-operations-to-move-all-balls-to-each-box__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 have n boxes. You are given a binary string boxes of length n, where b...
minimum-number-of-operations-to-move-all-balls-to-each-box
minimum-number-of-operations-to-move-all-balls-to-each-box__02__java
Array
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou have n boxes. You are given a binary string boxes of length n, where b...
maximum-score-from-performing-multiplication-operations
maximum-score-from-performing-multiplication-operations__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 two 0-indexed integer arrays nums and multipliers of size n ...
maximum-score-from-performing-multiplication-operations
maximum-score-from-performing-multiplication-operations__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 two 0-indexed integer arrays nums and multipliers of size n ...
maximize-palindrome-length-from-subsequences
maximize-palindrome-length-from-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\nYou are given two strings, word1 and word2. You want to construct a string...
sort-features-by-popularity
sort-features-by-popularity__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 array features where features[i] is a single word t...
count-items-matching-a-rule
count-items-matching-a-rule__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 array items, where each items[i] = [typei, colori, namei]...
closest-dessert-cost
closest-dessert-cost__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 would like to make dessert and are preparing to buy the ingredients. Y...
equal-sum-arrays-with-minimum-number-of-operations
equal-sum-arrays-with-minimum-number-of-operations__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 arrays of integers nums1 and nums2, possibly of differen...
equal-sum-arrays-with-minimum-number-of-operations
equal-sum-arrays-with-minimum-number-of-operations__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\nYou are given two arrays of integers nums1 and nums2, possibly of differen...
car-fleet-ii
car-fleet-ii__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\nThere are n cars traveling at different speeds in the same direction along...
shortest-path-in-a-hidden-grid
shortest-path-in-a-hidden-grid__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\nThis is an interactive problem.\n\nThere is a robot in a hidden grid, and ...
find-nearest-point-that-has-the-same-x-or-y-coordinate
find-nearest-point-that-has-the-same-x-or-y-coordinate__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 two integers, x and y, which represent your current location...
check-if-number-is-a-sum-of-powers-of-three
check-if-number-is-a-sum-of-powers-of-three__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 true if it is possible to represent n as the su...
sum-of-beauty-of-all-substrings
sum-of-beauty-of-all-substrings__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThe beauty of a string is the difference in frequencies between the most f...
sum-of-beauty-of-all-substrings
sum-of-beauty-of-all-substrings__02__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThe beauty of a string is the difference in frequencies between the most f...
count-pairs-of-nodes
count-pairs-of-nodes__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 undirected graph defined by an integer n, the number of n...
check-if-binary-string-has-at-most-one-segment-of-ones
check-if-binary-string-has-at-most-one-segment-of-ones__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 binary string s ​​​​​without leading zeros, return true​​​ if s co...
minimum-elements-to-add-to-form-a-given-sum
minimum-elements-to-add-to-form-a-given-sum__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 limit and goal. The a...
number-of-restricted-paths-from-first-to-last-node
number-of-restricted-paths-from-first-to-last-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\nThere is an undirected weighted connected graph. You are given a positive ...
number-of-restricted-paths-from-first-to-last-node
number-of-restricted-paths-from-first-to-last-node__02__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is an undirected weighted connected graph. You are given a positive ...
make-the-xor-of-all-segments-equal-to-zero
make-the-xor-of-all-segments-equal-to-zero__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 nums​​​ and an integer k​​​​​. The XOR of a segment...
maximize-the-beauty-of-the-garden
maximize-the-beauty-of-the-garden__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 is a garden of n flowers, and each flower has an integer beauty valu...
check-if-one-string-swap-can-make-strings-equal
check-if-one-string-swap-can-make-strings-equal__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two strings s1 and s2 of equal length. A string swap is an o...
find-center-of-star-graph
find-center-of-star-graph__01__java
Graph
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere is an undirected star graph consisting of n nodes labeled from 1 to ...
maximum-average-pass-ratio
maximum-average-pass-ratio__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\nThere is a school that has classes of students and each class will be havi...
maximum-score-of-a-good-subarray
maximum-score-of-a-good-subarray__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 array of integers nums (0-indexed) and an integer k.\n\nT...
count-pairs-of-equal-substrings-with-minimum-difference
count-pairs-of-equal-substrings-with-minimum-difference__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 firstString and secondString that are 0-indexed ...
second-largest-digit-in-a-string
second-largest-digit-in-a-string__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 alphanumeric string s, return the second largest numerical digit ...
second-largest-digit-in-a-string
second-largest-digit-in-a-string__02__java
Bit Manipulation
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an alphanumeric string s, return the second largest numerical digit ...
design-authentication-manager
design-authentication-manager__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 is an authentication system that works with authentication tokens. F...
maximum-number-of-consecutive-values-you-can-make
maximum-number-of-consecutive-values-you-can-make__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 coins of length n which represents the n co...
maximize-score-after-n-operations
maximize-score-after-n-operations__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 nums, an array of positive integers of size 2 * n. You must ...
maximum-ascending-subarray-sum
maximum-ascending-subarray-sum__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 positive integers nums, return the maximum possible sum ...
number-of-orders-in-the-backlog
number-of-orders-in-the-backlog__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 a 2D integer array orders, where each orders[i] = [pricei, a...
maximum-value-at-a-given-index-in-a-bounded-array
maximum-value-at-a-given-index-in-a-bounded-array__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 positive integers: n, index, and maxSum. You want to c...
count-pairs-with-xor-in-a-range
count-pairs-with-xor-in-a-range__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\nGiven a (0-indexed) integer array nums and two integers low and high, retu...
implement-trie-ii-prefix-tree
implement-trie-ii-prefix-tree__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\nA trie (pronounced as \"try\") or prefix tree is a tree data structure use...
number-of-different-integers-in-a-string
number-of-different-integers-in-a-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 word that consists of digits and lowercase English ...
minimum-number-of-operations-to-reinitialize-a-permutation
minimum-number-of-operations-to-reinitialize-a-permutation__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 even integer n​​​​​​. You initially have a permutation pe...