The Java codebase is organized as a Maven project. Here is the pom.xml.

Computing the parity of a word

Parity1.h Parity1.java

Computing the parity of a word

Parity2.h Parity2.java

Computing the parity of a word

Parity3.h Parity3.java

Computing the parity of a word

Parity4.h Parity4.java

Swap bits

swap_bits.h SwapBits.java

Reverse bits

Reverse_bits.cc ReverseBits.java

Find a closest integer with the same weight

Closest_int_same_bits.cc ClosestIntSameBits.java

Compute x * y without arithmetical operators

MultiplyShiftAdd.cc MultiplyShiftAdd.java

Compute x/y

Division.cc Division.java

Compute x^y

power-x-y.cc PowerXY.java

Reverse digits

reverse-integer.cc ReverseInteger.java

Check if a decimal integer is a palindrome

palindrome-number.cc PalindromeNumber.java

Generate uniform random numbers

Uniform_random_number_generation.cc UniformRandomNumberGeneration.java

Rectangle intersection

Intersect_rectangle.cc IntersectRectangle.java

The Dutch national flag problem

dutch_national_flag_slow_inplace.cc DutchNationalFlagSlowInplace.java

The Dutch national flag problem

dutch_national_flag_two_passes.cc DutchNationalFlagTwoPasses.java

The Dutch national flag problem

Dutch_national_flag.cc DutchNationalFlag.java

Increment an arbitrary-precision integer

plus-one.cc PlusOne.java

Multiply two arbitrary-precision integers

Bignumber_multiplication.cc BigNumberMultiplication.java

Advancing through an array

jump-game.cc JumpGame.java

Delete duplicates from a sorted array

remove-duplicates-from-sorted-array.cc RemoveDuplicatesFromSortedArray.java

Buy and sell a stock once

buy-and-sell-stock.cc BuyAndSellStock.java

Buy and sell a stock twice

buy-and-sell-stock-twice.cc BuyAndSellStockTwice.java

Enumerate all primes to n

prime-sieve-basic.cc PrimeSieveBasic.java

Enumerate all primes to n

Prime_sieve.cc PrimeSieve.java

Permute the elements of an array

Permutation_array1.h PermutationArray1.java

Permute the elements of an array

Permutation_array2.h PermutationArray2.java

Compute the next permutation

Next_permutation.cc NextPermutation.java

Sample offline data

Offline_sampling.h OfflineSampling.java

Sample online data

Reservoir_sampling.cc ReservoirSampling.java

Compute a random permutation

compute_random_permutation.cc ComputeRandomPermutation.java

Compute a random subset

Online_sampling.cc OnlineSampling.java

Generate nonuniform random numbers

nonuniform_random_number_generation.cc NonUniformRandomNumberGeneration.java

The Sudoku checker problem

sudoku_check.cc SudokuCheck.java

Compute the spiral ordering of a 2D array

Spiral_matrix_clockwise.cc SpiralMatrixClockwise.java

Compute the spiral ordering of a 2D array

Spiral_matrix.cc SpiralMatrix.java

Rotate a 2D array

Matrix_rotation_naive.cc MatrixRotationNaive.java

Rotate a 2D array

Matrix_rotation_constant.cc MatrixRotationConstant.java

Compute rows in Pascal’s Triangle

pascal-triangle-1.cc PascalTriangle1.java

Interconvert strings and integers

Interconverting_string_integer.cc InterconvertingStringInteger.java

Base conversion

Convert_base.cc ConvertBase.java

Compute the spreadsheet column encoding

Spreadsheet_encoding.cc SpreadsheetEncoding.java

Replace and remove

Replace_and_remove.cc ReplaceAndRemove.java

Test palindromicity

valid-palindrome.cc ValidPalindrome.java

Reverse all the words in a sentence

Reverse_words.cc ReverseWords.java

Compute all mnemonics for a phone number

Phone_mnemonic.cc PhoneMnemonic.java

The look-and-say problem

look-and-say.cc LookAndSay.java

Convert from Roman to decimal

roman-to-integer.cc RomanToInteger.java

Compute all valid IP addresses

valid-IP-address.cc ValidIPAddress.java

Write a string sinusoidally

snake-string.cc SnakeString.java

Implement run-length encoding

Run_length_compression.cc RunLengthCompression.java

Find the first occurrence of a substring

rabin-karp.cc RabinKarp.java

Find the first occurrence of a substring

Linked_list_prototype.h LinkedListPrototypeTemplate.java

Merge two sorted lists

Merge_sorted_lists.h MergeSortedLists.java

Reverse a single sublist

reverse_linked_list_from_s_to_f.cc ReverseLinkedListFromSToF.java

Test for cyclicity

Checking_cycle.h CheckingCycle.java

Test for cyclicity

Checking_cycle_alternative.cc CheckingCycleAlternative.java

Test for overlapping lists - lists are cycle-free

Overlapping_lists_no_cycle.h OverlappingListsNoCycle.java

Test for overlapping lists - lists may have cycles

Overlapping_lists.cc OverlappingLists.java

Delete a node from a singly linked list

Deletion_list.cc DeletionList.java

Remove the kth last element from a list

Remove_kth_last_list.cc RemoveKthLastList.java

Remove duplicates from a sorted list

remove-duplicates-sorted-list.cc RemoveDuplicatesSortedList.java

Implement cyclic right shift for singly linked lists

cyclic-right-shift.cc CyclicRightShift.java

Implement even-odd merge

Even_odd_merge_linked_list.cc EvenOddMergeLinkedList.java

Test whether a singly linked list is palindromic

Palindrome_linked_list.cc PalindromeLinkedList.java

Implement list pivoting

list-pivoting.cc ListPivoting.java

Add list-based integers

add-two-number-list.cc AddTwoNumberList.java

Implement a stack with max API

Stack_with_max.h StackWithMax.java

Implement a stack with max API

Stack_with_max_improved.cc StackWithMaxImproved.java

Evaluate RPN expressions

RPN.cc RPN.java

Test a string over ‘’{,},(,),[,]’’ for well-formedness

valid-parentheses.cc ValidParentheses.java

Normalize pathnames

normalized_pathnames.cc NormalizedPathnames.java

Search a postings list

Search_postings_list_recursive.cc SearchPostingsListRecursive.java

Search a postings list

Search_postings_list_iterative.cc SearchPostingsListIterative.java

Compute buildings with a sunset view

View_sunset.cc ViewSunset.java

Compute binary tree nodes in order of increasing depth

Binary_tree_level_order.cc BinaryTreeLevelOrder.java

Implement a circular queue

Circular_queue.cc CircularQueue.java

Implement a queue using stacks

Queue_from_stacks.cc QueueFromStacks.java

Implement a queue with max API

Queue_with_max_alternative.h QueueWithMaxAlternative.java

Implement a queue with max API

Queue_with_max.cc QueueWithMax.java

Implement a queue with max API

Binary_tree_prototype.h BinaryTreePrototypeTemplate.java

Test if a binary tree is height-balanced

Balanced_binary_tree.cc BalancedBinaryTree.java

Test if a binary tree is symmetric

Symmetric_binary_tree.cc SymmetricBinaryTree.java

Compute the lowest common ancestor in a binary tree

Lowest_common_ancestor_no_parent.cc LowestCommonAncestorNoParent.java

Compute the LCA when nodes have parent pointers

Lowest_common_ancestor.cc LowestCommonAncestor.java

Sum the root-to-leaf paths in a binary tree

sum-root-to-leaf-binary-tree.cc SumRootToLeafBinaryTree.java

Find a root to leaf path with specified sum

path-sum-binary-tree.cc PathSumBinaryTree.java

Implement an inorder traversal without recursion

BST_sorted_order.cc BSTSortedOrder.java

Implement a preorder traversal without recursion

binary-tree-preorder-traversal-iterative.cc BinaryTreePreorderTraversalIterative.java

Compute the kth node in an inorder traversal

k-th_node_binary_tree.cc KThNodeBinaryTree.java

Compute the successor

Successor.cc Successor.java

Implement an inorder traversal with O(1) space

Inorder_traversal_with_parent.cc InorderTraversalWithParent.java

Reconstruct a binary tree from traversal data

Reconstruct_binary_tree_pre_in_orders.cc ReconstructBinaryTreePreInorders.java

Reconstruct a binary tree from a preorder traversal with markers

Reconstruct_preorder_with_null.cc ReconstructPreorderWithNull.java

Form a linked list from the leaves of a binary tree

Connect_leaves_binary_tree.cc ConnectLeavesBinaryTree.java

Compute the exterior of a binary tree

Exterior_binary_tree.cc ExteriorBinaryTree.java

Compute the right sibling tree

populating-next-right-pointers.cc PopulatingNextRightPointers.java

Implement locking in a binary tree

Binary_tree_lock.cc BinaryTreeLock.java

Merge sorted files

Merge_sorted_arrays.h MergeSortedArrays.java

Sort an increasing-decreasing array

sort_k-increasing-decreasing_array.cc SortKIncreasingDecreasingArray.java

Sort an almost-sorted array

Approximate_sort.cc ApproximateSort.java

Compute the k closest stars

Closest_stars.cc ClosestStars.java

Compute the median of online data

Online_median.cc OnlineMedian.java

Compute the k largest elements in a max-heap

k-largest-elements-binary-heap.cc KLargestElementsBinaryHeap.java

Implement a stack API using a heap

Stack_queue_using_heap.cc StackQueueUsingHeap.java

Implement a stack API using a heap

Bentleybsearch.cc BentleyBsearch.java

Search a sorted array for first occurrence of k

Binary_search_first_k.cc BinarySearchFirstK.java

Search a sorted array for entry equal to its index

Binary_search_Ai=i.cc BinarySearchAiEqI.java

Search a cyclically sorted array

Binary_search_circular_array.cc BinarySearchCircularArray.java

Search a cyclically sorted array

Binary_search_circular_array_with_duplicates.cc BinarySearchCircularArrayWithDuplicates.java

Compute the integer square root

square-root-int.cc SquareRootInt.java

Compute the real square root

Square_root.cc SquareRoot.java

Search in a 2D sorted array

Matrix_search.cc MatrixSearch.java

Find the min and max simultaneously

Finding_min_max.cc FindingMinMax.java

Find the kth largest element

order_statistic.cc OrderStatistic.java

Find the missing IP address

Missing_element.cc MissingElement.java

Find the duplicate and missing elements

Find_missing_and_duplicate_XOR.cc FindMissingAndDuplicateXOR.java

Find the duplicate and missing elements

Hash_dictionary.cc HashDictionary.java

Test for palindromic permutations

Can_string_be_palindrome_hash.h CanStringBePalindromeHash.java

Is an anonymous letter constructible?

Anonymous_letter.cc AnonymousLetter.java

Implement an ISBN cache

LRUCache.cc LRUCache.java

Compute the LCA, optimizing for close ancestors

Lowest_common_ancestor_hash.cc LowestCommonAncestorHash.java

Find the nearest repeated entries in an array

Nearest_repetition.cc NearestRepetition.java

Find the smallest subarray covering all values

Smallest_subarray_covering_set.h SmallestSubarrayCoveringSet.java

Find the smallest subarray covering all values

Smallest_subarray_covering_set_stream.h SmallestSubarrayCoveringSetStream.java

Find smallest subarray sequentially covering all values

Subseq_cover.cc SubseqCover.java

Find the longest subarray with distinct entries

longest-subarray-with-distinct-entries.cc LongestSubarrayWithDistinctEntries.java

Find the length of a longest contained interval

longest-contained-range.cc LongestContainedRange.java

Compute the average of the top three scores

average-top-3-scores.cc AverageTop3Scores.java

Compute all string decompositions

substring-with-concatenation-of-all-words.cc SubstringWithConcatenationOfAllWords.java

Test the Collatz conjecture

Collatz_conjecture.cc CollatzConjecture.java

Compute the intersection of two sorted arrays

Intersect_sorted_arrays1.h IntersectSortedArrays1.java

Compute the intersection of two sorted arrays

Intersect_sorted_arrays2.h IntersectSortedArrays2.java

Compute the intersection of two sorted arrays

Intersect_sorted_arrays3.h IntersectSortedArrays3.java

Merge two sorted arrays

merge-two-sorted-arrays-in-place.cc MergeTwoSortedArraysInPlace.java

Remove first-name duplicates

Eliminate_duplicate.cc EliminateDuplicate.java

Render a calendar

Rendering_calendar.cc RenderingCalendar.java

Merging intervals

insert-interval.cc InsertInterval.java

Compute the union of intervals

Union_intervals.cc UnionIntervals.java

Partitioning and sorting an array with many repeated entries

partition-array.cc PartitionArray.java

Team photo day - 1

Team_photo_1.cc TeamPhoto1.java

Implement a fast sorting algorithm for lists

insertion-sort-list.cc InsertionSortList.java

Implement a fast sorting algorithm for lists

sort-list.cc SortList.java

Compute a salary threshold

Completion_search.cc CompletionSearch.java

Compute a salary threshold

BST_prototype.h BinarySearchTreePrototypeTemplate.java

Test if a binary tree satisfies the BST property

is_binary_tree_a_BST.cc IsBinaryTreeABST.java

Test if a binary tree satisfies the BST property

is_binary_tree_a_BST_BFS.cc IsBinaryTreeABSTBFS.java

Find the first key greater than a given value in a BST

Search_BST_first_larger_k.cc SearchBSTFirstLargerK.java

Find the k largest elements in a BST

Find_k_largest_BST.cc FindKLargestBST.java

Compute the LCA in a BST

BST_lowest_common_ancestor.cc BSTLowestCommonAncestor.java

Reconstruct a BST from traversal data

Rebuild_BST_preorder.cc RebuildBSTPreorder.java

Reconstruct a BST from traversal data

Rebuild_BST_preorder_better.cc RebuildBSTPreorderBetter.java

Find the closest entries in three sorted arrays

Minimum_distance_3_sorted_arrays.cc MinimumDistance3SortedArrays.java

Enumerate numbers of the form a + b sqrt(2)

Generating_a_b_sqrt2.cc GeneratingABSqrt2.java

Enumerate numbers of the form a + b sqrt(2)

generating-a-b-sqrt2-improved.cc GeneratingABSqrt2Improved.java

Build a minimum height BST from a sorted array

Build_BST_from_sorted_array.cc BuildBSTFromSortedArray.java

Insertion and deletion in a BST

insertion-deletion-BST.cc InsertionDeletionBST.java

Test if three BST nodes are totally ordered

Descendant_and_ancestor.cc DescendantAndAncestor.java

The range lookup problem

range-lookup-BST.cc RangeLookupBST.java

Add credits

AddingCredits.cc AddingCredits.java

The Towers of Hanoi problem

tower_hanoi.cc TowerHanoi.java

Generate all nonattacking placements of n-Queens

n-queens.cc NQueens.java

Generate permutations

permutations-alternative.cc PermutationsAlternative.java

Generate permutations

permutations.cc Permutations.java

Generate the power set

Power_set_alternative.cc PowerSetAlternative.java

Generate the power set

Power_set.cc PowerSet.java

Generate all subsets of size k

combinations.cc Combinations.java

Generate strings of matched parens

generate-parentheses.cc GenerateParentheses.java

Generate palindromic decompositions

palindrome-partitioning.cc PalindromePartitioning.java

Generate binary trees

unique-binary-trees-all.cc UniqueBinaryTreesAll.java

Implement a Sudoku solver

Sudoku_solve.cc SudokuSolve.java

Compute a Gray code

gray-code-backtrack.cc GrayCodeBacktrack.java

Compute a Gray code

gray-code.cc GrayCode.java

Compute the diameter of a tree

Tree_diameter.cc TreeDiameter.java

Compute the diameter of a tree

fibonacci.cc Fibonacci.java

Compute the diameter of a tree

Max-sum_subarray.cc MaxSumSubarray.java

Count the number of score combinations

Score_combination.cc ScoreCombination.java

Compute the Levenshtein distance

Levenshtein_distance.cc LevenshteinDistance.java

Count the number of ways to traverse a 2D array

Number_ways.cc NumberWays.java

Compute the binomial coefficients

Computing_binomial_coefficients.cc ComputingBinomialCoefficients.java

Search for a sequence in a 2D array

String_in_matrix.cc StringInMatrix.java

The knapsack problem

0-1_knapsack.cc ZeroOneKnapsack.java

The bedbathandbeyond.com problem

Word_breaking.cc WordBreaking.java

Find the minimum weight path in a triangle

triangle.cc Triangle.java

Pick up coins for maximum gain

Picking_up_coins.cc PickingUpCoins.java

Count the number of moves to climb stairs

number-steps.cc NumberSteps.java

The pretty printing problem

Pretty_printing.cc PrettyPrinting.java

Find the longest nondecreasing subsequence

Longest_nondecreasing_subsequence_n2.h LongestNondecreasingSubsequenceN2.java

Compute an optimum assignment of tasks

Task_assignment.cc TaskAssignment.java

Schedule to minimize waiting time

Minimum_waiting_time.cc MinimumWaitingTime.java

The interval covering problem

points_covering_intervals_sorting.cc PointsCoveringIntervalsSorting.java

The 3-sum problem

3-sum.cc ThreeSum.java

Find the majority element

Search_majority.cc SearchMajority.java

The gasup problem

Gassing_up.cc GassingUp.java

Compute the maximum water trapped by a pair of vertical lines

container-with-most-water.cc ContainerWithMostWater.java

Compute the largest rectangle under the skyline

Largest_rectangle_under_skyline.h LargestRectangleUnderSkyline.java

Search a maze

Search_maze.cc SearchMaze.java

Paint a Boolean matrix

Painting_iterative.cc PaintingIterative.java

Paint a Boolean matrix

Painting_recursive.cc PaintingRecursive.java

Compute enclosed regions

surrounded-regions.cc SurroundedRegions.java

Deadlock detection

2-exists.cc TwoExists.java

Clone a graph

clone-graph.cc CloneGraph.java

Making wired connections

Wiring_circuit_board.cc WiringCircuitBoard.java

Transform one string to another

Transform_string_to_other.cc TransformStringToOther.java

Team photo day - 2

Team_photo_2.cc TeamPhoto2.java

Compute a shortest path with fewest edges

Shortest_path_fewest_edges.cc ShortestPathFewestEdges.java

Implement caching for a multithreaded dictionary

s1.cc S1Alternative.java

Implement caching for a multithreaded dictionary

s2.cc S2Alternative.java

Analyze two unsynchronized interleaved threads

two_thread_increment.cc TwoThreadIncrement.java

Implement synchronization for two interleaving threads

odd_even.cc OddEven.java

Implement a thread pool

simple_web_server.cc SimpleWebServer.java

Implement a thread pool

thread_per_task_webserver.cc ThreadPerTaskWebserver.java

Implement a thread pool

task_execution_web_server.cc TaskExecutionWebServer.java

Deadlock

lock_ordering_bug.cc LockOrderingBug.java

Deadlock

lock_ordering_works.cc LockOrderingWorks.java

The readers-writers problem

rw.cc RW.java

Test the Collatz conjecture in parallel

collatz.cc Collatz.java

Pass-by-reference vs. pass-by-value

polymorphismproblems.cc

Pass-by-reference vs. pass-by-value

polymorphismproblemsfixed.cc

Smart pointers

smartpointers.cc

Default methods

passbyvaluebug.cc

Updating a map

mapupdate1.cc

Updating a map

mapupdate2.cc

Updating a map

mapupdate3.cc

Updating a map

mapupdate4.cc

Updating a map

mapupdate5.cc

Fast function calls

badmacro.cc

Fast function calls

inlineexample.cc

Template functions

minmaxtemplate.cc

Template functions

minmaxtemplatemove.cc

Run-time type identification

badrtti.cc

Run-time type identification

badrtti2.cc

Run-time type identification

goodrtti.cc

List, ArrayList, and LinkedList

BadArrayStore.java

List, ArrayList, and LinkedList

BadArrayListStore.java

String vs. StringBuilder

StringConcatenation.java

String vs. StringBuilder

StringConcatenationStringBuilder.java

Static initialization

BasicStaticInitializer.java

Static initialization

StaticInitializer.java

Creational Patterns

maze_game.h MazeGame.java

Creational Patterns

ordinary_maze_game.h OrdinaryMazeGame.java

Creational Patterns

magic_maze_game.h MagicMazeGame.java

Creational Patterns

maze_game_main.cc MazeGameMain.java

Compute the greatest common divisor

GCD1.h GCD1.java

Find the first missing positive entry

first-missing-positive.cc FirstMissingPositive.java

Buy and sell a stock k times

Max_difference_k_pairs.cc MaxDifferenceKPairs.java

Compute the maximum product of all entries but one

Biggest_product_n-1.cc BiggestProductNMinus1.java

Compute the maximum product of all entries but one

Biggest_product_n-1_math.cc BiggestProductNMinus1Math.java

Compute the longest contiguous increasing subarray

Longest_increasing_subarray.cc LongestIncreasingSubarray.java

Rotate an array

Rotate_array_permutation.h RotateArrayPermutation.java

Rotate an array

Rotate_array.h RotateArray.java

Identify positions attacked by rooks

rook-attack.cc RookAttack.java

Justify text

justify-text.cc JustifyText.java

Implement list zipping

Zipping_list.cc ZippingList.java

Copy a postings list

Copying_postings_list.cc CopyingPostingsList.java

Compute the longest substring with matching parens

longest-valid-parentheses.cc LongestValidParentheses.java

Compute the maximum of a sliding window

Sliding_window.cc SlidingWindow.java

Implement a postorder traversal without recursion

binary-tree-postorder-traversal-iterative-alternative.cc BinaryTreePostorderTraversalIterativeAlternative.java

Implement a postorder traversal without recursion

binary-tree-postorder-traversal-iterative.cc BinaryTreePostorderTraversalIterative.java

Compute fair bonuses

bonus.cc Bonus.java

Compute fair bonuses

bonus-improved.cc BonusImproved.java

Search a sorted array of unknown length

Binary_search_unknown_length.cc BinarySearchUnknownLength.java

Search in two sorted arrays

Find_kth_element_in_two_sorted_arrays.cc FindKthElementInTwoSortedArrays.java

Find the kth largest element - large n, small k

k-th_largest_element_large_n.cc KthLargestElementLargeN.java

Find an element that appears only once

Find_element_appears_once.cc FindElementAppearsOnce.java

Find the line through the most points

Line_most_points.cc LineMostPoints.java

Find the shortest unique prefix

Shortest_unique_prefix.cc ShortestUniquePrefix.java

Convert a sorted doubly linked list into a BST

Sorted_list_to_BST.cc SortedListToBST.java

Convert a BST to a sorted doubly linked list

BST_to_sorted_doubly_list.cc BSTToSortedDoublyList.java

Merge two BSTs

Merge_two_BSTs.cc MergeTwoBSTs.java

The view from above

View_from_above.cc ViewFromAbove.java

Implement regular expression matching

Regular_expression.cc RegularExpression.java

Synthesize an expression

Add_operators_in_string.cc AddOperatorsInString.java

Count inversions

Count_inversions.cc CountInversions.java

Draw the skyline

drawing_skylines_alternative.cc DrawingSkylinesAlternative.java

Measure with defective jugs

Three_jugs.cc ThreeJugs.java

Compute the maximum subarray sum in a circular array

Maximum_subarray_in_circular_array.cc MaximumSubarrayInCircularArray.java

Compute the maximum subarray sum in a circular array

Maximum_subarray_in_circular_array_constant_space.cc MaximumSubarrayInCircularArrayConstantSpace.java

Determine the critical height

Height_determination.cc HeightDetermination.java

Find the maximum 2D subarray

Max_submatrix_rectangle.cc MaxSubmatrixRectangle.java

Find the maximum 2D subarray

Max_submatrix_square.cc MaxSubmatrixSquare.java

Find the maximum 2D subarray

Max_submatrix_rectangle_improved.cc MaxSubmatrixRectangleImproved.java

Implement Huffman coding

Huffman_encoding.cc HuffmanEncoding.java

Trapping water

trapping-rain-water.cc TrappingRainWater.java

Search for a pair-sum in an abs-sorted array

Search_a_pair_sorted_array.cc SearchAPairSortedArray.java

The heavy hitter problem

Search_frequent_items.cc SearchFrequentItems.java

Find the longest subarray whose sum <= k

Longest_subarray_k_improved.cc LongestSubarrayKImproved.java

Road network

Road_network.cc RoadNetwork.java

Test if arbitrage is possible

Arbitrage.cc Arbitrage.java