Datasets:
slug stringlengths 3 79 | solution_id stringlengths 13 89 | primary_algorithm stringclasses 22
values | verified null | messages listlengths 3 3 |
|---|---|---|---|---|
two-sum | two-sum__01__java | Hash Table | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven an array of integers nums and an integer target, return indices of t... |
add-two-numbers | add-two-numbers__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 non-empty linked lists representing two non-negative int... |
longest-substring-without-repeating-characters | longest-substring-without-repeating-characters__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, find the length of the longest substring without duplica... |
median-of-two-sorted-arrays | median-of-two-sorted-arrays__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\nGiven two sorted arrays nums1 and nums2 of size m and n respectively, retu... |
longest-palindromic-substring | longest-palindromic-substring__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 the longest palindromic substring in s.\n\n### Ex... |
longest-palindromic-substring | longest-palindromic-substring__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 string s, return the longest palindromic substring in s.\n\n### Ex... |
zigzag-conversion | zigzag-conversion__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\nThe string \"PAYPALISHIRING\" is written in a zigzag pattern on a given nu... |
reverse-integer | reverse-integer__01__java | Math | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven a signed 32-bit integer x, return x with its digits reversed. If rev... |
string-to-integer-atoi | string-to-integer-atoi__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\nImplement the myAtoi(string s) function, which converts a string to a 32-b... |
palindrome-number | palindrome-number__01__java | Math | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven an integer x, return true if x is a palindrome, and false otherwise.... |
regular-expression-matching | regular-expression-matching__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 an input string s and a pattern p, implement regular expression matc... |
regular-expression-matching | regular-expression-matching__02__java | Dynamic Programming | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven an input string s and a pattern p, implement regular expression matc... |
container-with-most-water | container-with-most-water__01__java | Two Pointers | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nYou are given an integer array height of length n. There are n vertical li... |
integer-to-roman | integer-to-roman__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\nSeven different symbols represent Roman numerals with the following values... |
roman-to-integer | roman-to-integer__01__java | Math | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nRoman numerals are represented by seven different symbols: I, V, X, L, C, ... |
longest-common-prefix | longest-common-prefix__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\nWrite a function to find the longest common prefix string amongst an array... |
3sum | 3sum__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, return all the triplets [nums[i], nums[j], nu... |
3sum-closest | 3sum-closest__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 of length n and an integer target, find three ... |
letter-combinations-of-a-phone-number | letter-combinations-of-a-phone-number__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 containing digits from 2-9 inclusive, return all possible l... |
letter-combinations-of-a-phone-number | letter-combinations-of-a-phone-number__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 string containing digits from 2-9 inclusive, return all possible l... |
4sum | 4sum__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 nums of n integers, return an array of all the unique quadr... |
remove-nth-node-from-end-of-list | remove-nth-node-from-end-of-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\nGiven the head of a linked list, remove the nth node from the end of the l... |
valid-parentheses | valid-parentheses__01__java | String | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven a string s containing just the characters '(', ')', '{', '}', '[' an... |
merge-two-sorted-lists | merge-two-sorted-lists__01__java | Recursion | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nYou are given the heads of two sorted linked lists list1 and list2.\n\nMer... |
merge-two-sorted-lists | merge-two-sorted-lists__02__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 are given the heads of two sorted linked lists list1 and list2.\n\nMer... |
generate-parentheses | generate-parentheses__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 n pairs of parentheses, write a function to generate all combination... |
merge-k-sorted-lists | merge-k-sorted-lists__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 array of k linked-lists lists, each linked-list is sorted... |
swap-nodes-in-pairs | swap-nodes-in-pairs__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 linked list, swap every two adjacent nodes and return its head. Yo... |
swap-nodes-in-pairs | swap-nodes-in-pairs__02__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 a linked list, swap every two adjacent nodes and return its head. Yo... |
reverse-nodes-in-k-group | reverse-nodes-in-k-group__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, reverse the nodes of the list k at a time... |
remove-duplicates-from-sorted-array | remove-duplicates-from-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\nGiven an integer array nums sorted in non-decreasing order, remove the dup... |
remove-element | remove-element__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 and an integer val, remove all occurrences of ... |
find-the-index-of-the-first-occurrence-in-a-string | find-the-index-of-the-first-occurrence-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 two strings needle and haystack, return the index of the first occur... |
divide-two-integers | divide-two-integers__01__java | Math | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven two integers dividend and divisor, divide two integers without using... |
substring-with-concatenation-of-all-words | substring-with-concatenation-of-all-words__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 a string s and an array of strings words. All the strings of... |
next-permutation | next-permutation__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 permutation of an array of integers is an arrangement of its members int... |
longest-valid-parentheses | longest-valid-parentheses__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 containing just the characters '(' and ')', return the leng... |
search-in-rotated-sorted-array | search-in-rotated-sorted-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\nThere is an integer array nums sorted in ascending order (with distinct va... |
find-first-and-last-position-of-element-in-sorted-array | find-first-and-last-position-of-element-in-sorted-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\nGiven an array of integers nums sorted in non-decreasing order, find the s... |
search-insert-position | search-insert-position__01__java | Binary Search | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven a sorted array of distinct integers and a target value, return the i... |
search-insert-position | search-insert-position__02__java | Binary Search | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven a sorted array of distinct integers and a target value, return the i... |
valid-sudoku | valid-sudoku__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\nDetermine if a 9 x 9 Sudoku board is valid. Only the filled cells need to ... |
sudoku-solver | sudoku-solver__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\nWrite a program to solve a Sudoku puzzle by filling the empty cells.\n\nA ... |
count-and-say | count-and-say__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\nThe count-and-say sequence is a sequence of digit strings defined by the r... |
combination-sum | combination-sum__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 array of distinct integers candidates and a target integer target... |
combination-sum | combination-sum__02__java | Backtracking | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven an array of distinct integers candidates and a target integer target... |
combination-sum-ii | combination-sum-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\nGiven a collection of candidate numbers (candidates) and a target number (... |
combination-sum-ii | combination-sum-ii__02__java | Backtracking | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven a collection of candidate numbers (candidates) and a target number (... |
first-missing-positive | first-missing-positive__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 integer array nums. Return the smallest positive integer... |
trapping-rain-water | trapping-rain-water__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 n non-negative integers representing an elevation map where the widt... |
multiply-strings | multiply-strings__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 num1 and num2 represented as strings, retu... |
wildcard-matching | wildcard-matching__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 an input string (s) and a pattern (p), implement wildcard pattern ma... |
wildcard-matching | wildcard-matching__02__java | Dynamic Programming | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven an input string (s) and a pattern (p), implement wildcard pattern ma... |
jump-game-ii | jump-game-ii__01__java | Greedy | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nYou are given a 0-indexed array of integers nums of length n. You are init... |
permutations | permutations__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 array nums of distinct integers, return all the possible permutat... |
permutations-ii | permutations-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\nGiven a collection of numbers, nums, that might contain duplicates, return... |
rotate-image | rotate-image__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 n x n 2D matrix representing an image, rotate the image b... |
group-anagrams | group-anagrams__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 strs, group the anagrams together. You can retur... |
group-anagrams | group-anagrams__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 array of strings strs, group the anagrams together. You can retur... |
powx-n | powx-n__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\nImplement pow(x, n), which calculates x raised to the power n (i.e., xn).\... |
n-queens | n-queens__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\nThe n-queens puzzle is the problem of placing n queens on an n x n chessbo... |
n-queens-ii | n-queens-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\nThe n-queens puzzle is the problem of placing n queens on an n x n chessbo... |
maximum-subarray | maximum-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\nGiven an integer array nums, find the subarray with the largest sum, and r... |
maximum-subarray | maximum-subarray__02__java | Dynamic Programming | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven an integer array nums, find the subarray with the largest sum, and r... |
spiral-matrix | spiral-matrix__01__java | Math | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven an m x n matrix, return all elements of the matrix in spiral order.\... |
spiral-matrix | spiral-matrix__02__java | Math | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven an m x n matrix, return all elements of the matrix in spiral order.\... |
jump-game | jump-game__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. You are initially positioned at the a... |
merge-intervals | merge-intervals__01__java | Sorting | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven an array of intervals where intervals[i] = [starti, endi], merge all... |
merge-intervals | merge-intervals__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 array of intervals where intervals[i] = [starti, endi], merge all... |
insert-interval | insert-interval__01__java | Sorting | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nYou are given an array of non-overlapping intervals intervals where interv... |
insert-interval | insert-interval__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 are given an array of non-overlapping intervals intervals where interv... |
length-of-last-word | length-of-last-word__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 of words and spaces, return the length of the ... |
spiral-matrix-ii | spiral-matrix-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 a positive integer n, generate an n x n matrix filled with elements ... |
permutation-sequence | permutation-sequence__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\nThe set [1, 2, 3, ..., n] contains a total of n! unique permutations.\n\nB... |
rotate-list | rotate-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\nGiven the head of a linked list, rotate the list to the right by k places.... |
unique-paths | unique-paths__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 robot on an m x n grid. The robot is initially located at the t... |
unique-paths | unique-paths__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 a robot on an m x n grid. The robot is initially located at the t... |
unique-paths | unique-paths__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\nThere is a robot on an m x n grid. The robot is initially located at the t... |
unique-paths-ii | unique-paths-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 m x n integer array grid. There is a robot initially loca... |
unique-paths-ii | unique-paths-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 m x n integer array grid. There is a robot initially loca... |
minimum-path-sum | minimum-path-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 a m x n grid filled with non-negative numbers, find a path from top ... |
valid-number | valid-number__01__java | String | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven a string s, return whether s is a valid number.\n\nFor example, all ... |
plus-one | plus-one__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 large integer represented as an integer array digits, wher... |
add-binary | add-binary__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 binary strings a and b, return their sum as a binary string.\n\n... |
text-justification | text-justification__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 strings words and a width maxWidth, format the text such... |
sqrtx | sqrtx__01__java | Binary Search | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven a non-negative integer x, return the square root of x rounded down t... |
climbing-stairs | climbing-stairs__01__java | Recursion | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nYou are climbing a staircase. It takes n steps to reach the top.\n\nEach t... |
climbing-stairs | climbing-stairs__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 climbing a staircase. It takes n steps to reach the top.\n\nEach t... |
simplify-path | simplify-path__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 an absolute path for a Unix-style file system, which always ... |
edit-distance | edit-distance__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 word1 and word2, return the minimum number of operations... |
set-matrix-zeroes | set-matrix-zeroes__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 m x n integer matrix matrix, if an element is 0, set its entire r... |
set-matrix-zeroes | set-matrix-zeroes__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 m x n integer matrix matrix, if an element is 0, set its entire r... |
search-a-2d-matrix | search-a-2d-matrix__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 integer matrix matrix with the following two proper... |
search-a-2d-matrix | search-a-2d-matrix__02__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 integer matrix matrix with the following two proper... |
sort-colors | sort-colors__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 array nums with n objects colored red, white, or blue, sort them ... |
minimum-window-substring | minimum-window-substring__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 two strings s and t of lengths m and n respectively, return the mini... |
combinations | combinations__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 two integers n and k, return all possible combinations of k numbers ... |
combinations | combinations__02__java | Backtracking | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven two integers n and k, return all possible combinations of k numbers ... |
subsets | subsets__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 array nums of unique elements, return all possible subset... |
subsets | subsets__02__java | Backtracking | null | [
{
"role": "system",
"content": "You are a competitive programming assistant. Given a problem, its examples, and a required algorithm/technique, write a correct Java solution."
},
{
"role": "user",
"content": "### Problem\nGiven an integer array nums of unique elements, return all possible subset... |
LeetCode Code-Gen Dataset — Java
4068 rows. Given a problem statement, its input/output examples, and a required algorithm/technique, generate a correct Java solution.
Part of a 4-language collection built from the same source: see the sibling Python, Java, C++, and JavaScript datasets.
Verification
Not execution-verified. There is currently no compiler/runtime harness for this language in the build pipeline (only Python has one). Rows are extracted directly from named solution approaches in doocs/leetcode, a well-maintained community solutions repo, so correctness is likely but not guaranteed. Treat this the way you'd treat any unverified scraped code dataset.
Source
Extracted from doocs/leetcode, which documents multiple named solution approaches per problem (e.g. "Dynamic Programming", "Two Pointers", "Divide and Conquer") -- this is what makes per-row algorithm labeling possible, since the same problem can appear multiple times with a different technique and different code each time.
Fields
| field | description |
|---|---|
slug |
LeetCode problem slug |
solution_id |
unique id: problem + approach index + language |
primary_algorithm |
normalized algorithm/technique label |
verified |
true/false for Python (execution-checked), null for other languages |
messages |
chat-format (system/user/assistant), ready for SFT |
Example row
{
"slug": "house-robber",
"primary_algorithm": "Dynamic Programming",
"messages": [
{"role": "system", "content": "You are a competitive programming assistant..."},
{"role": "user", "content": "### Problem\n...\n### Algorithm\nDynamic Programming"},
{"role": "assistant", "content": "```java\n...\n```"}
]
}
Known gaps
- SQL/database problems excluded (wrong problem type for a code-execution harness)
- Design/class problems (LRU Cache, iterators) excluded -- they need a sequence of method calls to test, not a single input -> output check
- Some
Brute Forcelabels are a fallback where the source didn't name a specific technique for that approach
- Downloads last month
- -