原创 LeetCode | Sqrt (x)
Implement int sqrt(int x). Compute and return the square root of x. //tag提示用binary search。要求的返回結果是int,不是實際的平方跟,用二分法找
原创 LeetCode | Invert Binary Tree
Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6
原创 LeetCode | Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3,3,1]. Note: Co
原创 Java中的RTTI與反射
個人理解,可能有誤。理解自《java編程思想》。 首先,什麼是RTTI? RTTI(run-time type information)指的是Java在運行時能夠獲得或判斷某個對象的類型信。以Shape, Circle, Squre,
原创 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
原创 LeetCode | Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings. //要求找到字符串數組中所有string的最長公共前綴 //用b
原创 LeetCode | Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the su
原创 LeetCode | Pow(x, n)
Implement pow(x, n). //tag提示用binary search,主要就是確定有多少個x來相乘。 //思想是對n進行二分。注意下n可能爲負數 public class Solution { public dou
原创 LeetCode | Add Binary
Given two binary strings, return their sum (also a binary string). For example, a = "11" b = "1" Return "100". //思想是
原创 LeetCode | Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum
原创 LeetCode | Divide Two Integers
Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. 要求不使
原创 LeetCode | Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last wo
原创 LeetCode | Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of o
原创 LeetCode | 3 Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in
原创 LeetCode | Plus One
Given a non-negative number represented as an array of digits, plus one to the number. The digits are stored such th