slug
stringlengths
3
79
solution_id
stringlengths
13
89
primary_algorithm
stringclasses
22 values
verified
null
messages
listlengths
3
3
word-search
word-search__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 m x n grid of characters board and a string word, return true if ...
remove-duplicates-from-sorted-array-ii
remove-duplicates-from-sorted-array-ii__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an integer array nums sorted in non-decreasing order, remove some du...
search-in-rotated-sorted-array-ii
search-in-rotated-sorted-array-ii__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\nThere is an integer array nums sorted in non-decreasing order (not necessa...
remove-duplicates-from-sorted-list-ii
remove-duplicates-from-sorted-list-ii__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the head of a sorted linked list, delete all nodes that have duplica...
remove-duplicates-from-sorted-list
remove-duplicates-from-sorted-list__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\nGiven the head of a sorted linked list, delete all duplicates such that ea...
largest-rectangle-in-histogram
largest-rectangle-in-histogram__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 of integers heights representing the histogram's bar height...
maximal-rectangle
maximal-rectangle__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 rows x cols binary matrix filled with 0's and 1's, find the larges...
partition-list
partition-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\nGiven the head of a linked list and a value x, partition it such that all ...
scramble-string
scramble-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\nWe can scramble a string s to get a string t using the following algorithm...
scramble-string
scramble-string__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 can scramble a string s to get a string t using the following algorithm...
merge-sorted-array
merge-sorted-array__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given two integer arrays nums1 and nums2, sorted in non-decreasing...
gray-code
gray-code__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\nAn n-bit gray code sequence is a sequence of 2n integers where:\n\n\tEvery...
subsets-ii
subsets-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\nGiven an integer array nums that may contain duplicates, return all possib...
subsets-ii
subsets-ii__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 an integer array nums that may contain duplicates, return all possib...
decode-ways
decode-ways__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 intercepted a secret message encoded as a string of numbers. The ...
reverse-linked-list-ii
reverse-linked-list-ii__01__java
Math
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the head of a singly linked list and two integers left and right whe...
restore-ip-addresses
restore-ip-addresses__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 valid IP address consists of exactly four integers separated by single d...
binary-tree-inorder-traversal
binary-tree-inorder-traversal__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, return the inorder traversal of its nodes...
binary-tree-inorder-traversal
binary-tree-inorder-traversal__02__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, return the inorder traversal of its nodes...
binary-tree-inorder-traversal
binary-tree-inorder-traversal__03__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 inorder traversal of its nodes...
unique-binary-search-trees-ii
unique-binary-search-trees-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\nGiven an integer n, return all the structurally unique BST's (binary searc...
unique-binary-search-trees
unique-binary-search-trees__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 n, return the number of structurally unique BST's (binary...
interleaving-string
interleaving-string__01__java
Memoization
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven strings s1, s2, and s3, find whether s3 is formed by an interleaving...
interleaving-string
interleaving-string__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 strings s1, s2, and s3, find whether s3 is formed by an interleaving...
validate-binary-search-tree
validate-binary-search-tree__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, determine if it is a valid binary search ...
recover-binary-search-tree
recover-binary-search-tree__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given the root of a binary search tree (BST), where the values of ...
same-tree
same-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 roots of two binary trees p and q, write a function to check if ...
same-tree
same-tree__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\nGiven the roots of two binary trees p and q, write a function to check if ...
symmetric-tree
symmetric-tree__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, check whether it is a mirror of itself (i...
binary-tree-level-order-traversal
binary-tree-level-order-traversal__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 level order traversal of its n...
binary-tree-zigzag-level-order-traversal
binary-tree-zigzag-level-order-traversal__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 zigzag level order traversal o...
maximum-depth-of-binary-tree
maximum-depth-of-binary-tree__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, return its maximum depth.\n\nA binary tre...
construct-binary-tree-from-preorder-and-inorder-traversal
construct-binary-tree-from-preorder-and-inorder-traversal__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven two integer arrays preorder and inorder where preorder is the preord...
construct-binary-tree-from-inorder-and-postorder-traversal
construct-binary-tree-from-inorder-and-postorder-traversal__01__java
Hash Table
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven two integer arrays inorder and postorder where inorder is the inorde...
binary-tree-level-order-traversal-ii
binary-tree-level-order-traversal-ii__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 bottom-up level order traversa...
convert-sorted-array-to-binary-search-tree
convert-sorted-array-to-binary-search-tree__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 nums where the elements are sorted in ascending ord...
convert-sorted-list-to-binary-search-tree
convert-sorted-list-to-binary-search-tree__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the head of a singly linked list where elements are sorted in ascend...
balanced-binary-tree
balanced-binary-tree__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a binary tree, determine if it is height-balanced.\n\n### Examples\n...
minimum-depth-of-binary-tree
minimum-depth-of-binary-tree__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a binary tree, find its minimum depth.\n\nThe minimum depth is the n...
minimum-depth-of-binary-tree
minimum-depth-of-binary-tree__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\nGiven a binary tree, find its minimum depth.\n\nThe minimum depth is the n...
path-sum
path-sum__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree and an integer targetSum, return true if t...
path-sum-ii
path-sum-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\nGiven the root of a binary tree and an integer targetSum, return all root-...
flatten-binary-tree-to-linked-list
flatten-binary-tree-to-linked-list__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, flatten the tree into a \"linked list\":\...
distinct-subsequences
distinct-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 strings s and t, return the number of distinct subsequences of s...
distinct-subsequences
distinct-subsequences__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 two strings s and t, return the number of distinct subsequences of s...
populating-next-right-pointers-in-each-node
populating-next-right-pointers-in-each-node__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 a perfect binary tree where all leaves are on the same level...
populating-next-right-pointers-in-each-node
populating-next-right-pointers-in-each-node__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\nYou are given a perfect binary tree where all leaves are on the same level...
populating-next-right-pointers-in-each-node-ii
populating-next-right-pointers-in-each-node-ii__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 binary tree\n\nstruct Node {\n int val;\n Node *left;\n Node *r...
populating-next-right-pointers-in-each-node-ii
populating-next-right-pointers-in-each-node-ii__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 binary tree\n\nstruct Node {\n int val;\n Node *left;\n Node *r...
pascals-triangle
pascals-triangle__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 numRows, return the first numRows of Pascal's triangle.\n...
pascals-triangle-ii
pascals-triangle-ii__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven an integer rowIndex, return the rowIndexth (0-indexed) row of the Pa...
triangle
triangle__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 triangle array, return the minimum path sum from top to bottom.\n\...
triangle
triangle__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 triangle array, return the minimum path sum from top to bottom.\n\...
best-time-to-buy-and-sell-stock
best-time-to-buy-and-sell-stock__01__java
Brute Force
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an array prices where prices[i] is the price of a given stoc...
best-time-to-buy-and-sell-stock-ii
best-time-to-buy-and-sell-stock-ii__01__java
Greedy
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an integer array prices where prices[i] is the price of a gi...
best-time-to-buy-and-sell-stock-ii
best-time-to-buy-and-sell-stock-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 integer array prices where prices[i] is the price of a gi...
best-time-to-buy-and-sell-stock-ii
best-time-to-buy-and-sell-stock-ii__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\nYou are given an integer array prices where prices[i] is the price of a gi...
best-time-to-buy-and-sell-stock-iii
best-time-to-buy-and-sell-stock-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 an array prices where prices[i] is the price of a given stoc...
binary-tree-maximum-path-sum
binary-tree-maximum-path-sum__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\nA path in a binary tree is a sequence of nodes where each pair of adjacent...
valid-palindrome
valid-palindrome__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\nA phrase is a palindrome if, after converting all uppercase letters into l...
word-ladder-ii
word-ladder-ii__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\nA transformation sequence from word beginWord to word endWord using a dict...
word-ladder
word-ladder__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 transformation sequence from word beginWord to word endWord using a dict...
word-ladder
word-ladder__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\nA transformation sequence from word beginWord to word endWord using a dict...
longest-consecutive-sequence
longest-consecutive-sequence__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 unsorted array of integers nums, return the length of the longest...
longest-consecutive-sequence
longest-consecutive-sequence__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\nGiven an unsorted array of integers nums, return the length of the longest...
sum-root-to-leaf-numbers
sum-root-to-leaf-numbers__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 the root of a binary tree containing digits from 0 to 9 only...
surrounded-regions
surrounded-regions__01__java
DFS
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nYou are given an m x n matrix board containing letters 'X' and 'O', captur...
surrounded-regions
surrounded-regions__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\nYou are given an m x n matrix board containing letters 'X' and 'O', captur...
palindrome-partitioning
palindrome-partitioning__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 string s, partition s such that every substring of the partition i...
palindrome-partitioning-ii
palindrome-partitioning-ii__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s, partition s such that every substring of the partition i...
clone-graph
clone-graph__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 reference of a node in a connected undirected graph.\n\nReturn a d...
gas-station
gas-station__01__java
Greedy
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n gas stations along a circular route, where the amount of gas a...
candy
candy__01__java
Greedy
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nThere are n children standing in a line. Each child is assigned a rating v...
single-number
single-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-empty array of integers nums, every element appears twice exce...
single-number
single-number__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 a non-empty array of integers nums, every element appears twice exce...
single-number-ii
single-number-ii__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 integer array nums where every element appears three times except...
single-number-ii
single-number-ii__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 integer array nums where every element appears three times except...
copy-list-with-random-pointer
copy-list-with-random-pointer__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 linked list of length n is given such that each node contains an additio...
copy-list-with-random-pointer
copy-list-with-random-pointer__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 linked list of length n is given such that each node contains an additio...
word-break
word-break__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 and a dictionary of strings wordDict, return true if s ca...
word-break
word-break__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 and a dictionary of strings wordDict, return true if s ca...
word-break-ii
word-break-ii__01__java
Dynamic Programming
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven a string s and a dictionary of strings wordDict, add spaces in s to ...
linked-list-cycle
linked-list-cycle__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 head, the head of a linked list, determine if the linked list has a ...
linked-list-cycle
linked-list-cycle__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 head, the head of a linked list, determine if the linked list has a ...
linked-list-cycle-ii
linked-list-cycle-ii__01__java
Two Pointers
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the head of a linked list, return the node where the cycle begins. I...
reorder-list
reorder-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 singly linked-list. The list can be represente...
binary-tree-preorder-traversal
binary-tree-preorder-traversal__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, return the preorder traversal of its node...
binary-tree-preorder-traversal
binary-tree-preorder-traversal__02__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, return the preorder traversal of its node...
binary-tree-preorder-traversal
binary-tree-preorder-traversal__03__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 preorder traversal of its node...
binary-tree-postorder-traversal
binary-tree-postorder-traversal__01__java
Recursion
null
[ { "role": "system", "content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution." }, { "role": "user", "content": "### Problem\nGiven the root of a binary tree, return the postorder traversal of its nod...
binary-tree-postorder-traversal
binary-tree-postorder-traversal__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 postorder traversal of its nod...
binary-tree-postorder-traversal
binary-tree-postorder-traversal__03__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 postorder traversal of its nod...
lru-cache
lru-cache__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 data structure that follows the constraints of a Least Recently U...
insertion-sort-list
insertion-sort-list__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 head of a singly linked list, sort the list using insertion sort...
sort-list
sort-list__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 head of a linked list, return the list after sorting it in ascen...
max-points-on-a-line
max-points-on-a-line__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 points where points[i] = [xi, yi] represents a point on ...
max-points-on-a-line
max-points-on-a-line__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 array of points where points[i] = [xi, yi] represents a point on ...
evaluate-reverse-polish-notation
evaluate-reverse-polish-notation__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 strings tokens that represents an arithmetic exp...
reverse-words-in-a-string
reverse-words-in-a-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\nGiven an input string s, reverse the order of the words.\n\nA word is defi...
reverse-words-in-a-string
reverse-words-in-a-string__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 an input string s, reverse the order of the words.\n\nA word is defi...