Unique Binary Search Trees II

Given n, generate all structurally unique BST’s (binary search trees) that store values 1...n.

Intersection of Two Linked Lists

Write a program to find the node at which the intersection of two singly linked lists begins. If the two linked lists have no intersection at all, return null. The linked lists must retain their original structure after the function returns. You may assume there are no cycles anywhere in the entire linked structure.

Unique Binary Search Trees

Given n, how many structurally unique BSTs (binary search trees) that store values 1...n?

Find the Missing Number

Given an array contains N numbers of 0 .. N, find which number doesn’t exist in the array.

Palindrome Linked List

Implement a function to check if a linked list is a palindrome. Can you do it in O(n) time and O(1) space?

Sort Integers

Given an integer array, sort it in ascending order. Use selection sort, bubble sort, insertion sort or any O(n2) algorithm.

Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

Ugly Number

Write a program to check whether a given number is an ugly number. Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7. One is also considered an ugly number.

Left Pad

You know what, left pad is javascript package and referenced by React: GitHub link. One day his author unpublished it, then a lot of javascript projects in the world broken. You can see from github it’s only 11 lines. You job is to implement the left pad function. If you do not know what left pad does, see examples below and guess.

Shape Factory

Factory is a design pattern in common usage. Implement a ShapeFactory that can generate correct shape. You can assume that we have only tree different shapes: Triangle, Square and Rectangle.