Flatten Binary Tree to Linked List

Flatten a binary tree to a fake “linked list” in pre-order traversal.

Swap Nodes in Pairs

Given a linked list, swap every two adjacent nodes and return its head.

Subarray Sum to Zero

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.

Identical Binary Tree

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.

Binary Tree Paths

Given a binary tree, return all root-to-leaf paths.

Happy Number

Write an algorithm to determine if a number is happy.

Count Digits in an Integer

The following snippet uses log() to find the number of digits in the integer x. The result is 5.

Least Significant Digits of Integer

Least significant digits of an integer can be obtained by performing modulo of power of 10. Note that modulo is the division remainder operator.

Java Generics

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

COMP2210 A2

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 c, and comp.