原创 [LeetCode] 415. Add Strings 解題報告
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2. Note: The len
原创 [LeetCode]414. Third Maximum Number 解題報告
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the m
原创 Effective Java 讀書筆記——39:必要時進行保護性拷貝
容易被破壞的內部約束條件 雖然如果沒有主動提供公共方法和變量,外部是無法修改類內部的數據的。但是,對象可能會在無意識的情況下提供幫助。例如,下面就是一個通過引用來修改類內部的數據,而破壞對象內部的約束條件的例子: public fina
原创 Effective Java 讀書筆記——41:慎用重載
先看一個使用重載錯誤的例子: public class CollectionClassifier { public static String classify(Set<?> s) { return "Set";
原创 Effective Java 讀書筆記——15:使可變性最小化
不可變類 不可變類是它的實例不能被修改的類。每個實例中所有的信息,必須在創建的時候提供,並在其整個對象週期內固定不變,例如:String,基本的包裝類,BigInteger和BigDecimal。不可變的類更加的易於設計、實現和使用。它們
原创 [LeetCode] 501. Find Mode in Binary Search Tree 解題報告
Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the
原创 [LeetCode] 467. Unique Substrings in Wraparound String 解題報告
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this:
原创 [LeetCode] 442. Find All Duplicates in an Array 解題報告
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once. Find
原创 [LeetCode] 56. Merge Intervals 解題報告
Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[15,18], retu
原创 [LeetCode] 447. Number of Boomerangs 解題報告
Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that th
原创 [LeetCode] 394. Decode String 解題報告
Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_strin
原创 [LeetCode] 451. Sort Characters By Frequency 解題報告
Given a string, sort it in decreasing order based on the frequency of characters. Example 1: Input: "tree" Output:
原创 [LeetCode] 435. Non-overlapping Intervals 解題報告
Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the inter
原创 [LeetCode] 452. Minimum Number of Arrows to Burst Balloons 解題報告
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the star
原创 [LeetCode] 279. Perfect Squares 解題報告
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum