Flatten a binary tree to a fake “linked list” in pre-order traversal.
Given a linked list, swap every two adjacent nodes and return its head.
Given an integer array, find a subarray where the sum of numbers is zero. Your code should return the index of the first number and the index of the last number.
Check if two binary trees are identical. Identical means the two binary trees have the same structure and every identical position has the same value.
Given a binary tree, return all root-to-leaf paths.
Write an algorithm to determine if a number is happy.
The following snippet uses
log() to find the number of digits in the integer
x. The result is 5.
Least significant digits of an integer can be obtained by performing modulo of power of 10. Note that modulo is the division remainder operator.
Data structures and collections help us organize data in our program. For example, the
TreeSet class is a collection data structure that always keep the objects sorted, and the
Stack class always keep the last object added at the front. Both classes are data structures built into the Java standard library
The goal of this assignment is to perform searching operations (min, max, kmin, kmax) from a generic collection using a Comparator. The collection and Comparator are passed into the methods as