Primitive Types |
4 |
Primitive Types |
CountBits.java |
NA |
Primitive Types |
4.1 |
Computing the parity of a word |
Parity.java |
NA |
Primitive Types |
4.2 |
Swap bits |
SwapBits.java |
NA |
Primitive Types |
4.3 |
Reverse bits |
ReverseBits.java |
NA |
Primitive Types |
4.4 |
Find a closest integer with the same weight |
ClosestIntSameWeight.java |
NA |
Primitive Types |
4.5 |
Compute product without arithmetical operators |
PrimitiveMultiply.java |
NA |
Primitive Types |
4.6 |
Compute quotient without arithmetical operators |
PrimitiveDivide.java |
NA |
Primitive Types |
4.7 |
Compute pow(x,y) |
PowerXY.java |
NA |
Primitive Types |
4.8 |
Reverse digits |
ReverseDigits.java |
NA |
Primitive Types |
4.9 |
Check if a decimal integer is a palindrome |
IsNumberPalindromic.java |
NA |
Primitive Types |
4.1 |
Generate uniform random numbers |
UniformRandomNumber.java |
NA |
Primitive Types |
4.11 |
Rectangle intersection |
RectangleIntersection.java |
NA |
Arrays |
5 |
Arrays |
EvenOddArray.java |
44 |
Arrays |
5.1 |
The Dutch national flag problem |
DutchNationalFlag.java |
45 |
Arrays |
5.2 |
Increment an arbitrary-precision integer |
IntAsArrayIncrement.java |
48 |
Arrays |
5.3 |
Multiply two arbitrary-precision integers |
IntAsArrayMultiply.java |
49 |
Arrays |
5.4 |
Advancing through an array |
AdvanceByOffsets.java |
50 |
Arrays |
5.5 |
Delete duplicates from a sorted array |
SortedArrayRemoveDups.java |
51 |
Arrays |
5.6 |
Buy and sell a stock once |
BuyAndSellStock.java |
52 |
Arrays |
5.7 |
Buy and sell a stock twice |
BuyAndSellStockTwice.java |
53 |
Arrays |
5.8 |
Computing an alternation |
AlternatingArray.java |
54 |
Arrays |
5.9 |
Enumerate all primes to n |
PrimeSieve.java |
55 |
Arrays |
5.1 |
Permute the elements of an array |
ApplyPermutation.java |
45 |
Arrays |
5.11 |
Compute the next permutation |
NextPermutation.java |
57 |
Arrays |
5.12 |
Sample offline data |
OfflineSampling.java |
NA |
Arrays |
5.13 |
Sample online data |
OnlineSampling.java |
NA |
Arrays |
5.14 |
Compute a random permutation |
RandomPermutation.java |
NA |
Arrays |
5.15 |
Compute a random subset |
RandomSubset.java |
NA |
Arrays |
5.16 |
Generate nonuniform random numbers |
NonuniformRandomNumber.java |
NA |
Arrays |
5.17 |
The Sudoku checker problem |
IsValidSudoku.java |
NA |
Arrays |
5.18 |
Compute the spiral ordering of a 2D array |
SpiralOrdering.java |
NA |
Arrays |
5.19 |
Rotate a 2D array |
MatrixRotation.java |
NA |
Arrays |
5.20 |
Compute rows in Pascal's Triangle |
PascalTriangle.java |
48 |
Strings |
6 |
Strings |
IsStringPalindromic.java |
60 |
Strings |
6.1 |
Interconvert strings and integers |
StringIntegerInterconversion.java |
62 |
Strings |
6.2 |
Base conversion |
ConvertBase.java |
65 |
Strings |
6.3 |
Compute the spreadsheet column encoding |
SpreadsheetEncoding.java |
66 |
Strings |
6.4 |
Replace and remove |
ReplaceAndRemove.java |
68 |
Strings |
6.5 |
Test palindromicity |
IsStringPalindromicPunctuation.java |
69 |
Strings |
6.6 |
Reverse all the words in a sentence |
ReverseWords.java |
70 |
Strings |
6.7 |
The look-and-say problem |
LookAndSay.java |
71 |
Strings |
6.8 |
Convert from Roman to decimal |
RomanToInteger.java |
72 |
Strings |
6.9 |
Compute all valid IP addresses |
ValidIpAddresses.java |
74 |
Strings |
6.1 |
Write a string sinusoidally |
SnakeString.java |
62 |
Strings |
6.11 |
Implement run-length encoding |
RunLengthCompression.java |
78 |
Strings |
6.12 |
Find the first occurrence of a substring |
SubstringMatch.java |
79 |
Linked Lists |
7 |
Linked Lists |
DeleteFromList.java |
94 |
Linked Lists |
7 |
Linked Lists |
InsertInList.java |
94 |
Linked Lists |
7 |
Linked Lists |
SearchInList.java |
94 |
Linked Lists |
7.1 |
Merge two sorted lists |
SortedListsMerge.java |
95 |
Linked Lists |
7.2 |
Reverse a single sublist |
ReverseSublist.java |
96 |
Linked Lists |
7.3 |
Test for cyclicity |
IsListCyclic.java |
98 |
Linked Lists |
7.4 |
Test for overlapping lists---lists are cycle-free |
DoTerminatedListsOverlap.java |
98 |
Linked Lists |
7.5 |
Test for overlapping lists---lists may have cycles |
DoListsOverlap.java |
100 |
Linked Lists |
7.6 |
Delete a node from a singly linked list |
DeleteNodeFromList.java |
101 |
Linked Lists |
7.7 |
Remove the kth last element from a list |
DeleteKthLastFromList.java |
102 |
Linked Lists |
7.8 |
Remove duplicates from a sorted list |
RemoveDuplicatesFromSortedList.java |
104 |
Linked Lists |
7.9 |
Implement cyclic right shift for singly linked lists |
ListCyclicRightShift.java |
105 |
Linked Lists |
7.1 |
Implement even-odd merge |
EvenOddListMerge.java |
95 |
Linked Lists |
7.11 |
Test whether a singly linked list is palindromic |
IsListPalindromic.java |
107 |
Linked Lists |
7.12 |
Implement list pivoting |
PivotList.java |
108 |
Linked Lists |
7.13 |
Add list-based integers |
IntAsListAdd.java |
109 |
Stacks and Queues |
8.1 |
Implement a stack with max API |
StackWithMax.java |
115 |
Stacks and Queues |
8.2 |
Evaluate RPN expressions |
EvaluateRpn.java |
116 |
Stacks and Queues |
8.3 |
Is a string well-formed? |
IsValidParenthesization.java |
117 |
Stacks and Queues |
8.4 |
Normalize pathnames |
DirectoryPathNormalization.java |
119 |
Stacks and Queues |
8.5 |
Compute buildings with a sunset view |
SunsetView.java |
121 |
Stacks and Queues |
8.6 |
Compute binary tree nodes in order of increasing depth |
TreeLevelOrder.java |
122 |
Stacks and Queues |
8.7 |
Implement a circular queue |
CircularQueue.java |
123 |
Stacks and Queues |
8.8 |
Implement a queue using stacks |
QueueFromStacks.java |
124 |
Stacks and Queues |
8.9 |
Implement a queue with max API |
QueueWithMax.java |
125 |
Binary Trees |
9.1 |
Test if a binary tree is height-balanced |
IsTreeBalanced.java |
132 |
Binary Trees |
9.2 |
Test if a binary tree is symmetric |
IsTreeSymmetric.java |
135 |
Binary Trees |
9.3 |
Compute the lowest common ancestor in a binary tree |
LowestCommonAncestor.java |
137 |
Binary Trees |
9.4 |
Compute the LCA when nodes have parent pointers |
LowestCommonAncestorWithParent.java |
138 |
Binary Trees |
9.5 |
Sum the root-to-leaf paths in a binary tree |
SumRootToLeaf.java |
139 |
Binary Trees |
9.6 |
Find a root to leaf path with specified sum |
PathSum.java |
140 |
Binary Trees |
9.7 |
Implement an inorder traversal without recursion |
TreeInorder.java |
143 |
Binary Trees |
9.8 |
Compute the kth node in an inorder traversal |
KthNodeInTree.java |
145 |
Binary Trees |
9.9 |
Compute the successor |
SuccessorInTree.java |
146 |
Binary Trees |
9.1 |
Implement an inorder traversal with constant space |
TreeWithParentInorder.java |
132 |
Binary Trees |
9.11 |
Reconstruct a binary tree from traversal data |
TreeFromPreorderInorder.java |
NA |
Binary Trees |
9.12 |
Reconstruct a binary tree from a preorder traversal with markers |
TreeFromPreorderWithNull.java |
NA |
Binary Trees |
9.13 |
Compute the leaves of a binary tree |
TreeConnectLeaves.java |
NA |
Binary Trees |
9.14 |
Compute the exterior of a binary tree |
TreeExterior.java |
NA |
Binary Trees |
9.15 |
Compute the right sibling tree |
TreeRightSibling.java |
NA |
Heaps |
10.1 |
Merge sorted files |
SortedArraysMerge.java |
152 |
Heaps |
10.2 |
Sort an increasing-decreasing array |
SortIncreasingDecreasingArray.java |
154 |
Heaps |
10.3 |
Sort an almost-sorted array |
SortAlmostSortedArray.java |
155 |
Heaps |
10.4 |
Compute the k closest stars |
KClosestStars.java |
157 |
Heaps |
10.5 |
Compute the median of online data |
OnlineMedian.java |
158 |
Heaps |
10.6 |
Compute the k largest elements in a max-heap |
KLargestInHeap.java |
159 |
Searching |
11.1 |
Search a sorted array for first occurrence of k |
SearchFirstKey.java |
177 |
Searching |
11.2 |
Search a sorted array for entry equal to its index |
SearchEntryEqualToIndex.java |
179 |
Searching |
11.3 |
Search a cyclically sorted array |
SearchShiftedSortedArray.java |
180 |
Searching |
11.4 |
Compute the integer square root |
IntSquareRoot.java |
181 |
Searching |
11.5 |
Compute the real square root |
RealSquareRoot.java |
182 |
Searching |
11.6 |
Search in a 2D sorted array |
SearchRowColSortedMatrix.java |
184 |
Searching |
11.7 |
Find the min and max simultaneously |
SearchForMinMaxInArray.java |
185 |
Searching |
11.8 |
Find the kth largest element |
KthLargestInArray.java |
NA |
Searching |
11.9 |
Find the missing IP address |
AbsentValueArray.java |
NA |
Searching |
11.1 |
Find the duplicate and missing elements |
SearchForMissingElement.java |
177 |
Hash Tables |
12 |
Hash Tables |
Anagrams.java |
187 |
Hash Tables |
12.1 |
Test for palindromic permutations |
IsStringPermutableToPalindrome.java |
190 |
Hash Tables |
12.2 |
Is an anonymous letter constructible? |
IsAnonymousLetterConstructible.java |
191 |
Hash Tables |
12.3 |
Implement an ISBN cache |
LruCache.java |
192 |
Hash Tables |
12.4 |
Compute the LCA, optimizing for close ancestors |
LowestCommonAncestorCloseAncestor.java |
194 |
Hash Tables |
12.5 |
Find the nearest repeated entries in an array |
NearestRepeatedEntries.java |
195 |
Hash Tables |
12.6 |
Find the smallest subarray covering all values |
SmallestSubarrayCoveringSet.java |
196 |
Hash Tables |
12.7 |
Find smallest subarray sequentially covering all values |
SmallestSubarrayCoveringAllValues.java |
198 |
Hash Tables |
12.8 |
Find the longest subarray with distinct entries |
LongestSubarrayWithDistinctValues.java |
199 |
Hash Tables |
12.9 |
Find the length of a longest contained interval |
LongestContainedInterval.java |
202 |
Hash Tables |
12.1 |
Compute all string decompositions |
StringDecompositionsIntoDictionaryWords.java |
190 |
Hash Tables |
12.11 |
Test the Collatz conjecture |
CollatzChecker.java |
NA |
Sorting |
13.1 |
Compute the intersection of two sorted arrays |
IntersectSortedArrays.java |
212 |
Sorting |
13.2 |
Merge two sorted arrays |
TwoSortedArraysMerge.java |
213 |
Sorting |
13.3 |
Computing the h-index |
HIndex.java |
214 |
Sorting |
13.4 |
Remove first-name duplicates |
RemoveDuplicates.java |
216 |
Sorting |
13.5 |
Smallest nonconstructible value |
SmallestNonconstructibleValue.java |
217 |
Sorting |
13.6 |
Render a calendar |
CalendarRendering.java |
217 |
Sorting |
13.7 |
Merging intervals |
IntervalAdd.java |
218 |
Sorting |
13.8 |
Compute the union of intervals |
IntervalsUnion.java |
222 |
Sorting |
13.9 |
Partitioning and sorting an array with many repeated entries |
GroupEqualEntries.java |
224 |
Sorting |
13.1 |
Team photo day---1 |
IsArrayDominated.java |
212 |
Sorting |
13.11 |
Implement a fast sorting algorithm for lists |
SortList.java |
227 |
Sorting |
13.12 |
Compute a salary threshold |
FindSalaryThreshold.java |
228 |
Binary Search Trees |
14 |
Binary Search Trees |
SearchInBst.java |
234 |
Binary Search Trees |
14.1 |
Test if a binary tree satisfies the BST property |
IsTreeABst.java |
252 |
Binary Search Trees |
14.2 |
Find the first key greater than a given value in a BST |
SearchFirstGreaterValueInBst.java |
238 |
Binary Search Trees |
14.3 |
Find the k largest elements in a BST |
KLargestValuesInBst.java |
239 |
Binary Search Trees |
14.4 |
Compute the LCA in a BST |
LowestCommonAncestorInBst.java |
240 |
Binary Search Trees |
14.5 |
Reconstruct a BST from traversal data |
BstFromPreorder.java |
242 |
Binary Search Trees |
14.6 |
Find the closest entries in three sorted arrays |
MinimumDistance3SortedArrays.java |
244 |
Binary Search Trees |
14.7 |
Enumerate extended integers |
ABSqrt2.java |
246 |
Binary Search Trees |
14.8 |
Build a minimum height BST from a sorted array |
BstFromSortedArray.java |
248 |
Binary Search Trees |
14.9 |
Test if three BST nodes are totally ordered |
DescendantAndAncestorInBst.java |
250 |
Binary Search Trees |
14.1 |
The range lookup problem |
RangeLookupInBst.java |
252 |
Binary Search Trees |
14.11 |
Add credits |
AddingCredits.java |
NA |
Recursion |
15 |
Recursion |
EuclideanGcd.java |
254 |
Recursion |
15.1 |
The Towers of Hanoi problem |
Hanoi.java |
256 |
Recursion |
15.2 |
Compute all mnemonics for a phone number |
PhoneNumberMnemonic.java |
259 |
Recursion |
15.3 |
Generate all nonattacking placements of n-Queens |
NQueens.java |
260 |
Recursion |
15.4 |
Generate permutations |
Permutations.java |
261 |
Recursion |
15.5 |
Generate the power set |
PowerSet.java |
262 |
Recursion |
15.6 |
Generate all subsets of size k |
Combinations.java |
265 |
Recursion |
15.7 |
Generate strings of matched parens |
EnumerateBalancedParentheses.java |
267 |
Recursion |
15.8 |
Generate palindromic decompositions |
EnumeratePalindromicDecompositions.java |
269 |
Recursion |
15.9 |
Generate binary trees |
EnumerateTrees.java |
271 |
Recursion |
15.1 |
Implement a Sudoku solver |
SudokuSolve.java |
256 |
Recursion |
15.11 |
Compute a Gray code |
GrayCode.java |
275 |
Dynamic Programming |
16 |
Dynamic Programming |
Fibonacci.java |
282 |
Dynamic Programming |
16 |
Dynamic Programming |
MaxSumSubarray.java |
282 |
Dynamic Programming |
16.1 |
Count the number of score combinations |
NumberOfScoreCombinations.java |
283 |
Dynamic Programming |
16.2 |
Compute the Levenshtein distance |
LevenshteinDistance.java |
285 |
Dynamic Programming |
16.3 |
Count the number of ways to traverse a 2D array |
NumberOfTraversalsMatrix.java |
287 |
Dynamic Programming |
16.4 |
Compute the binomial coefficients |
BinomialCoefficients.java |
289 |
Dynamic Programming |
16.5 |
Search for a sequence in a 2D array |
IsStringInMatrix.java |
291 |
Dynamic Programming |
16.6 |
The knapsack problem |
Knapsack.java |
292 |
Dynamic Programming |
16.7 |
Building a search index for domains |
IsStringDecomposableIntoWords.java |
293 |
Dynamic Programming |
16.8 |
Find the minimum weight path in a triangle |
MinimumWeightPathInATriangle.java |
295 |
Dynamic Programming |
16.9 |
Pick up coins for maximum gain |
PickingUpCoins.java |
296 |
Dynamic Programming |
16.1 |
Count the number of moves to climb stairs |
NumberOfTraversalsStaircase.java |
283 |
Dynamic Programming |
16.11 |
The pretty printing problem |
PrettyPrinting.java |
300 |
Dynamic Programming |
16.12 |
Find the longest nondecreasing subsequence |
LongestNondecreasingSubsequence.java |
NA |
Greedy Algorithms and Invariants |
17 |
Greedy Algorithms and Invariants |
MakingChange.java |
303 |
Greedy Algorithms and Invariants |
17.1 |
Compute an optimum assignment of tasks |
TaskPairing.java |
306 |
Greedy Algorithms and Invariants |
17.2 |
Schedule to minimize waiting time |
MinimumWaitingTime.java |
309 |
Greedy Algorithms and Invariants |
17.3 |
The interval covering problem |
MinimumPointsCoveringIntervals.java |
312 |
Greedy Algorithms and Invariants |
17.3 |
The interval covering problem |
TwoSum.java |
312 |
Greedy Algorithms and Invariants |
17.4 |
The 3-sum problem |
ThreeSum.java |
314 |
Greedy Algorithms and Invariants |
17.5 |
Find the majority element |
MajorityElement.java |
315 |
Greedy Algorithms and Invariants |
17.6 |
The gasup problem |
RefuelingSchedule.java |
317 |
Greedy Algorithms and Invariants |
17.7 |
Compute the maximum water trapped by a pair of vertical lines |
MaxTrappedWater.java |
320 |
Greedy Algorithms and Invariants |
17.8 |
Compute the largest rectangle under the skyline |
LargestRectangleUnderSkyline.java |
323 |
Graphs |
18.1 |
Search a maze |
SearchMaze.java |
334 |
Graphs |
18.2 |
Paint a Boolean matrix |
MatrixConnectedRegions.java |
335 |
Graphs |
18.3 |
Compute enclosed regions |
MatrixEnclosedRegions.java |
336 |
Graphs |
18.4 |
Deadlock detection |
DeadlockDetection.java |
340 |
Graphs |
18.5 |
Clone a graph |
GraphClone.java |
341 |
Graphs |
18.6 |
Making wired connections |
IsCircuitWirable.java |
343 |
Graphs |
18.7 |
Transform one string to another |
StringTransformability.java |
345 |
Graphs |
18.8 |
Team photo day---2 |
MaxTeamsInPhotograph.java |
347 |
Honors Class |
24.1 |
Compute the greatest common divisor |
Gcd.java |
NA |
Honors Class |
24.2 |
Find the first missing positive entry |
FirstMissingPositiveEntry.java |
NA |
Honors Class |
24.3 |
Buy and sell a stock at most k times |
BuyAndSellStockKTimes.java |
NA |
Honors Class |
24.4 |
Compute the maximum product of all entries but one |
MaxProductAllButOne.java |
NA |
Honors Class |
24.5 |
Compute the longest contiguous increasing subarray |
LongestIncreasingSubarray.java |
NA |
Honors Class |
24.6 |
Rotate an array |
RotateArray.java |
NA |
Honors Class |
24.7 |
Identify positions attacked by rooks |
RookAttack.java |
NA |
Honors Class |
24.8 |
Justify text |
LeftRightJustifyText.java |
NA |
Honors Class |
24.9 |
Implement list zipping |
ZipList.java |
NA |
Honors Class |
24.1 |
Copy a postings list |
CopyPostingList.java |
NA |
Honors Class |
24.11 |
Compute the longest substring with matching parens |
LongestSubstringWithMatchingParentheses.java |
NA |
Honors Class |
24.12 |
Compute the maximum of a sliding window |
MaxOfSlidingWindow.java |
NA |
Honors Class |
24.13 |
Compute fair bonuses |
Bonus.java |
NA |
Honors Class |
24.14 |
Search a sorted array of unknown length |
SearchUnknownLengthArray.java |
NA |
Honors Class |
24.15 |
Search in two sorted arrays |
KthLargestElementInTwoSortedArrays.java |
NA |
Honors Class |
24.16 |
Find the kth largest element---large n, small k |
KthLargestElementInLongArray.java |
NA |
Honors Class |
24.17 |
Find an element that appears only once |
ElementAppearingOnce.java |
NA |
Honors Class |
24.18 |
Find the line through the most points |
LineThroughMostPoints.java |
NA |
Honors Class |
24.19 |
Convert a sorted doubly linked list into a BST |
SortedListToBst.java |
NA |
Honors Class |
24.2 |
Convert a BST to a sorted doubly linked list |
BstToSortedList.java |
NA |
Honors Class |
24.21 |
Merge two BSTs |
BstMerge.java |
NA |
Honors Class |
24.22 |
Implement regular expression matching |
RegularExpression.java |
NA |
Honors Class |
24.23 |
Synthesize an expression |
InsertOperatorsInString.java |
NA |
Honors Class |
24.24 |
Count inversions |
CountInversions.java |
NA |
Honors Class |
24.25 |
Draw the skyline |
DrawingSkyline.java |
NA |
Honors Class |
24.26 |
Measure with defective jugs |
DefectiveJugs.java |
NA |
Honors Class |
24.27 |
Compute the maximum subarray sum in a circular array |
MaximumSubarrayInCircularArray.java |
NA |
Honors Class |
24.28 |
Determine the critical height |
MaxSafeHeight.java |
NA |
Honors Class |
24.29 |
Find the maximum 2D subarray |
MaxSquareSubmatrix.java |
NA |
Honors Class |
24.29 |
Find the maximum 2D subarray |
MaxSubmatrix.java |
NA |
Honors Class |
24.3 |
Implement Huffman coding |
HuffmanCoding.java |
NA |
Honors Class |
24.31 |
Trapping water |
MaxWaterTrappable.java |
NA |
Honors Class |
24.32 |
The heavy hitter problem |
SearchFrequentItems.java |
NA |
Honors Class |
24.33 |
Find the longest subarray with sum constraint |
LongestSubarrayWithSumConstraint.java |
NA |
Honors Class |
24.34 |
Road network |
RoadNetwork.java |
NA |
Honors Class |
24.35 |
Test if arbitrage is possible |
Arbitrage.java |
NA |