原创 LeetCode 之 Binary Tree Paths
Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2
原创 LeetCode 之 Product of Array Except Self
Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product o
原创 LeetCode 之 Isomorphic Strings
Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be
原创 LeetCode 之 Bulb Switcher
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On th
原创 LeetCode 之 Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find t
原创 LeetCode 之 Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from th
原创 LeetCode 之 Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ... 1 is read of
原创 LeetCode 之 Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only m
原创 LeetCode 之 Remove Linked List Elements
Remove all elements from a linked list of integers that have value val. ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5
原创 LeetCode 之 Add Binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". 這道題並不複
原创 LeetCode 之 Bulls and Cows
You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to gu
原创 LeetCode 之 Implement strStr()
Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of h
原创 LeetCode 之 Reverse Integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 從低到高位,對每個數字乘以翻轉後的權值,在求和就行
原创 LeetCode 之 Missing Number
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.
原创 LeetCode 之 Compare Version Numbers
Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 return -1,