Solve LeetCode problems in Typst with beautiful PDF output, built-in test cases, and automatic visualization.
Import the package and start solving. All test cases are built-in and ready to use.
Professional PDF rendering with syntax highlighting, tree visualization, and more.
Instant pass/fail indicators with side-by-side comparison of expected vs actual.
Visual rendering for binary trees, linked lists, and chessboards.
Explore algorithms with Typst's expressive functional programming syntax.
Custom comparators, extra test cases, and flexible rendering options.
// Import the package
// For local development, use lib.typ directly
#import "lib.typ": problem, test
// Display the problem
#problem(1)
// Write your solution
#let solution(nums, target) = {
let d = (:)
for (i, num) in nums.enumerate() {
if str(target - num) in d {
return (d.at(str(target - num)), i)
}
d.insert(str(num), i)
}
}
// Test with built-in cases!
#test(1, solution)
Download the complete PDF with all 69 problems and reference solutions.