CJCoding With Joseph
15free / daySign inCreate account
TitleOpen
411
Push a Value onto an Array StackAn array-backed stack stores its values in an int array and keeps top as the index of the item currently on top.
easyNot startedSolve
412
Pop and Peek on an Array StackThe array stack can already push and display itself.
easyNot startedSolve
413
Is the Array Stack Empty or Full?push, pop and peek all lean on two tiny status methods, and both of them are missing.
easyNot startedSolve
414
Display an Array Stack Bottom to TopThe stack works, but printing one shows nothing useful.
easyNot startedSolve
415
Push onto a Linked-Node StackThis stack has no array and no capacity - it is a chain of nodes, and the field top points at the front of that chain.
easyNot startedSolve
416
Push and Pop a Generic StackMyStack<T> holds any type by storing the values in an Object array.
easyNot startedSolve
417
Enqueue Into an Array QueueShiftQueue stores its values in a plain array and always keeps the front at index 0.
easyNot startedSolve
418
Dequeue by Shifting LeftShiftQueue keeps the front of the queue at index 0, so removing it means sliding every later value down one slot.
easyNot startedSolve
419
Enqueue With WraparoundCircularQueue never shifts.
easyNot startedSolve
420
Dequeue From a Circular QueueCircularQueue removes a value by moving front forward instead of shifting the whole array.
easyNot startedSolve
421
Enqueue at the Tail of a Linked QueueLinkedQueue adds at the tail and removes at the head, so it tracks both ends.
easyNot startedSolve
422
Peek at the Front of a Linked QueueLinkedQueue is complete except for peek(), the method that looks at the front of the queue without removing anything.
easyNot startedSolve
423
Transfer One Stack Into the OtherStackQueue fakes a queue out of two stacks: enqueue pushes onto inbox, while dequeue and peek take from outbox, which holds values already flipped into arrival order.
easyNot startedSolve
424
Serve the Print QueuePrintQueue holds waiting job names in a java.util.Queue so the printer serves them in submission order.
easyNot startedSolve
425
Add a Node to the FrontAn IntList keeps its nodes in a chain that starts at head.
easyNot startedSolve
426
Add a Node to the EndaddFirst() is already written for you.
easyNot startedSolve
427
Remove the First NodeUnlinking the head node is the mirror image of addFirst(): read the value out, then let head skip over the node being dropped.
easyNot startedSolve
428
Count the NodesThis IntList stores no counter, so size() has to find out the hard way: start a cursor at head and follow next until it runs off the end, counting as it goes.
easyNot startedSolve
429
Find the Index of the Smallest ValueNumberList owns an int array and its size.
easyNot startedSolve
430
Finish the Bubble Sort Inner LoopNumberList owns an int array and its size.
easyNot startedSolve
431
Drop the Key Into Place (Insertion Sort)Insertion sort never swaps.
easyNot startedSolve
432
Finish the Binary Search Middle StepThis NumberList is built from values already in ascending order.
easyNot startedSolve
433
Add to the Front of a DequeArrayDequeInt holds up to 5 ints in a circular array.
easyNot startedSolve
457
Find the Smallest Value in a BSTComplete findMin() so it returns the smallest value stored in the tree.
easyNot startedSolve
458
Find the Largest Value With RecursionComplete the private helper findMax(Node node) so that findMax() returns the largest value in the tree.
easyNot startedSolve
459
Search a BST for a ValueComplete contains(int value) so it returns true when value is stored in the tree and false when it is not.
easyNot startedSolve
460
Insert a Value Into a BSTComplete the private helper insert(Node node, int value) so that insert(int value) adds a value to the tree in the right place.
easyNot startedSolve
461
Print a BST In OrderComplete the private helper inOrder(Node node, StringBuilder sb) so that inOrder() returns every value in the tree, in in-order, separated by spaces.
easyNot startedSolve
462
Print a BST in Pre-OrderComplete the private helper preOrder(Node node, StringBuilder sb) so that preOrder() returns every value in the tree, in pre-order, separated by spaces.
easyNot startedSolve
463
Print a BST in Post-OrderComplete the private helper postOrder(Node node, StringBuilder sb) so that postOrder() returns every value in the tree, in post-order, separated by spaces.
easyNot startedSolve
464
Count the Nodes in a BSTComplete the private helper size(Node node) so that size() returns how many values are stored in the tree.
easyNot startedSolve
465
Measure the Height of a BSTComplete the private helper height(Node node) so that height() returns the height of the tree.
easyNot startedSolve
466
Count the Leaves of a BSTComplete the private helper countLeaves(Node node) so that countLeaves() returns how many leaves the tree has.
easyNot startedSolve
467
Find How Deep a Value SitsComplete depthOf(int value) so it returns how deep value sits in the tree, or -1 when value is not in the tree.
easyNot startedSolve
468
Find a Heap Node's Parent and ChildrenComplete the three index helpers parent(int i), leftChild(int i) and rightChild(int i) in this min heap.
easyNot startedSolve
469
Insert Into a Min Heap (Sift Up)Complete insert(int value) so it adds a value to the min heap and keeps the heap rule true.
easyNot startedSolve
470
Insert Into a Max HeapComplete insert(int value) so it adds a value to the max heap and keeps the heap rule true.
easyNot startedSolve
471
Check Whether an Array Is a Min HeapComplete isMinHeap(int[] values) so it returns true when the array, read as a heap, follows the min-heap rule, and false when any parent is bigger than one of its children.
easyNot startedSolve
472
Sort Numbers With a PriorityQueueComplete sortedOrder(int[] values) so it returns every value from smallest to largest as one string with a single space between values, letting Java's PriorityQueue do the sorting.
easyNot startedSolve
473
Turn a PriorityQueue Into a Max HeapComplete largest(int[] scores, int k) so it returns the k largest scores from biggest to smallest, as one string with a single space between them.
easyNot startedSolve
474
Update an AVL Node's HeightComplete updateHeight(Node node) so every node's stored height stays correct while values are inserted.
easyNot startedSolve
475
Compute an AVL Node's Balance FactorComplete balanceFactor(Node node) so the tree can report how lopsided each node is.
easyNot startedSolve
476
Check That Every Node Is BalancedComplete isBalanced(Node node) so isAVL() reports whether every node in the tree obeys the AVL balance rule.
easyNot startedSolve
552
Read a Slot Safely From a Dynamic ArrayA DynamicArray keeps its values in an ordinary int array called data, but only the first size slots are in use.
easyNot startedSolve
553
Append to a Dynamic ArrayA DynamicArray makes itself bigger when it runs out of room, so adding to it can never fail.
easyNot startedSolve
554
Double a Full Array With growA Java array can never change its length, so a dynamic array grows by moving house: it makes a longer array, copies its values across, and uses the new array from then on.
easyNot startedSolve
555
Search Only the Used SlotsSearching a dynamic array is a plain scan from the front, with one trap: the array data is usually longer than the list.
easyNot startedSolve
556
Shift Right to Insert at an IndexTo put a value in the middle of an array, everything from that position onward has to move one slot to the right first.
easyNot startedSolve
557
Shift Left to Remove at an IndexRemoving from the middle of an array leaves a gap, and a dynamic array closes it by moving every later value one slot to the left.
easyNot startedSolve
558
Remove the First Match Using Two HelpersA class that already has good helpers should use them.
easyNot startedSolve
559
Add to the Front of a Doubly Linked ListIn a doubly linked list every DNode has a prev link as well as a next link.
easyNot startedSolve
560
Add to the Back of a Doubly Linked ListBecause the list keeps a tail reference, adding at the back needs no walk at all: it is O(1), the same cost as adding at the front.
easyNot startedSolve
561
Remove the First Node of a Doubly Linked ListRemoving the first node of a doubly linked list has one step more than in a singly linked list: the node that becomes the new head still holds a prev link to the node being dropped, and that link has to be cleared.
easyNot startedSolve
562
Insert After a Node in a Doubly Linked ListInserting in the middle of a doubly linked list never shifts anything.
easyNot startedSolve
563
Unlink a Middle Node From a Doubly Linked ListA node in the middle of a doubly linked list can unlink itself, because it can see both of its neighbours.
easyNot startedSolve
564
Read the Kth Value From the End of a Doubly Linked ListA singly linked list can only be read from the front, so reaching a value counted from the end means working out its position first.
easyNot startedSolve
434
Build the Array Stack CoreThe two fields are declared but nothing sets them up, so a new stack is unusable.
mediumNot startedSolve
435
Finish the Linked-Node Stackpush and the display are written.
mediumNot startedSolve
436
Check for Balanced BracketsA stack is the classic way to check bracket nesting: an opener waits on the stack until its own closer shows up.
mediumNot startedSolve
437
Track the Minimum With a Second StackMinStack keeps two stacks: main holds every value, and mins holds only the values that were the smallest so far, so getMin() can just read the top of mins.
mediumNot startedSolve
438
Evaluate a Postfix ExpressionIn postfix notation the operator comes after its two operands, so 3 4 + means 3 + 4.
mediumNot startedSolve
439
Guard an Empty Array QueueShiftQueue can already accept values and print itself, but nothing stops it reading a slot it does not own.
mediumNot startedSolve
440
Build the Circular Queue CoreThis CircularQueue has its three fields declared but never set up, and both methods that move values are missing.
mediumNot startedSolve
441
Circular Queue With front and rearRingQueue tracks front and rear instead of a size counter, which creates a problem: front == rear would mean both empty and completely full.
mediumNot startedSolve
442
Build Both Ends of a Linked QueueLinkedQueue adds at the tail and removes at the head, so the two missing methods must keep head, tail and size telling the same story.
mediumNot startedSolve
443
Queue From Two StacksStackQueue must behave like a queue while owning nothing but two stacks.
mediumNot startedSolve
444
Find a Node by Index and by ValueA linked list has no random access, so both lookups are the same walk with a different stopping rule: one counts steps, the other compares values.
mediumNot startedSolve
445
Insert and Remove at a PositionBoth methods share one invariant: to change a link you must be standing on the node BEFORE the target, because a singly linked node cannot see backwards.
mediumNot startedSolve
446
Remove the First Node Holding a ValueUnlike a counted walk, this one stops on data you cannot predict, so carry two cursors: previous stays one node behind current, because the link you must rewire lives in previous.
mediumNot startedSolve
447
Keep the Tail Pointer HonestA TailedIntList holds head, tail and a size counter so that appending costs O(1) instead of the walk IntList needs.
mediumNot startedSolve
448
Remove the Last NodeThe tail pointer hands you the last node instantly, but it does not save you here: to unlink it you need the node BEFORE it, and a singly linked node cannot look back.
mediumNot startedSolve
449
Walk a Doubly Linked List Both WaysEvery DNode carries a prev as well as a next, so the same chain can be read from either end.
mediumNot startedSolve
450
Remove the Last Node of a Doubly Linked ListIn a singly linked list, removing the last node requires walking the chain to find the node before tail.
mediumNot startedSolve
451
Reverse the List In PlaceReversing means re-aiming every next pointer at the node behind it instead of building a second list.
mediumNot startedSolve
452
Find the Middle NodeYou could call size() and walk half of it, but one pass is enough: move slow one node at a time and fast two, and when fast runs off the end slow is standing on the middle.
mediumNot startedSolve
453
Build Selection Sort From Its HelperNumberList gives you two finished helpers: findMinIndex(int start), which returns the INDEX of the smallest value from start onward, and a private swap(int i, int j).
mediumNot startedSolve
454
Write Binary Search From ScratchThis NumberList is built from values that are already in ascending order, so it can be searched by halving the range instead of scanning it.
mediumNot startedSolve
455
Keep a List Sorted as You InsertSortedIntList stays in ascending order at all times, so there is no sort to run afterwards.
mediumNot startedSolve
456
Build Both Ends of a DequeA deque has four doors: add and remove at each end.
mediumNot startedSolve
477
Find the Kth Smallest Value in a BSTComplete kthSmallest(int k) and its helper walkInOrder(Node node, int k) so the tree can answer the question: what is the k-th smallest value?
mediumNot startedSolve
478
List the Values Between Low and HighComplete collect(Node node, int low, int high, StringBuilder sb) so valuesBetween(low, high) returns every value from low to high, both ends included, smallest first and separated by single spaces.
mediumNot startedSolve
479
Check Whether a Tree Is a Valid BSTComplete the private helper isValid(Node node, Integer min, Integer max) so BSTValidator.isValid(root) returns true only when the whole tree follows the BST rule.
mediumNot startedSolve
480
Find the Lowest Common Ancestor in a BSTComplete lowestCommonAncestor(int a, int b) so it returns the value of the lowest common ancestor of a and b, or -1 when either value is not in the tree.
mediumNot startedSolve
481
Print a BST Level by Level With a QueueComplete printLevels() so it prints the tree one level per line, from the root down.
mediumNot startedSolve
482
Remove the Minimum From a Min HeapComplete removeMin() so it takes the smallest value out of the heap, returns it, and leaves the rest of the array a valid min heap.
mediumNot startedSolve
483
Build a Max Heap From an Unsorted ArrayComplete the MaxHeap(int[] values) constructor and the private siftDown(int i) method, so a heap can be built from an unsorted array in one go instead of inserting the values one at a time.
mediumNot startedSolve
484
Keep the K Largest Values With a Min HeapComplete add(int score) and kthBest() so the Leaderboard keeps only the k highest scores it has ever seen, however many scores arrive.
mediumNot startedSolve
485
Rotate an AVL Subtree RightComplete rotateRight(Node y), the move an AVL tree uses to fix a subtree whose left side has grown two levels taller than its right.
mediumNot startedSolve
486
Rotate an AVL Subtree LeftComplete rotateLeft(Node x) so this AVL tree can fix itself when values keep arriving on the right.
mediumNot startedSolve
487
Delete a Value From a BSTComplete remove(Node node, int value) and its helper minValue(Node node) so tree.remove(value) takes value out of the tree and leaves a tree that still follows the BST rule.
hardNot startedSolve
488
Walk a BST In Order With a StackComplete BSTIterator so it hands out a tree's values one at a time, smallest first: next() returns the next value in sorted order, and hasNext() says whether any values are left.
hardNot startedSolve
489
Heap Sort an Array In PlaceComplete HeapSort so heapSort(int[] a) sorts the array from smallest to largest IN PLACE, using the array itself as a max heap.
hardNot startedSolve
490
Track the Running Median With Two HeapsComplete add(int value) and median() so MedianTracker can report the median of every number added so far, at any moment, without sorting the numbers again each time.
hardNot startedSolve
491
Insert Into an AVL Tree and RebalanceFinish a self-balancing AVL tree: complete rotateRight, rotateLeft and the rebalancing step at the end of insert, so the tree is balanced again after every insert.
hardNot startedSolve