原创 【字符串處理系列】最長重複子串

最長重複子串是指在字符串中中找出兩個子串(可以覆蓋),他們的公共前綴最長;所以可以採用後綴數組的解法,首先得到所有後綴數組並排序,然後找出所有相鄰兩個子串之間的最長前綴;由於字符串比較的時間複雜度是O(N),排序算法的時間複雜度是O(Nl

原创 [LeetCode] Path Sum && Path Sum II

Path Sum: https://oj.leetcode.com/problems/path-sum/ 要求解從根到葉子節點的路徑的和,首先要從根節點遍歷到葉子節點,所以我們需要對樹進行深度優先遍歷,採用遞歸的方法解決;每遍歷到一個節點

原创 Java中equals方法和hashCode方法

《Effective Java》第2版的第9條條款要求“覆蓋equals方法的類總要覆蓋hashCode方法”,如果不這麼做,就違反了Object.hashCode() 的通用約定,導致該類的實例無法與基於散列的集合(HashMap, H

原创 Activity啓動流程、Looper及Handler

android.app.ActivityManager ActivityManager負責ActivityThread的創建,Activity生命週期的維護 android.app.ActivityThread 該類中的main方法是An

原创 [LeetCode] Candy

There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these child

原创 Android異步任務

本文主要探討Android平臺提供的各種異步加載機制,包括它們的適用場景、使用方法等。 1. AsynTask AsynTask適用於最長可以持續幾秒鐘的短時間的操作,對於長時間的操作,建議使用java.util.concurrent包下

原创 ART

ART(Andorid Runtime)是Google在新版Android系統中引入的運行時環境;在此之前,Android一直使用Dalvik虛擬機作爲java的運行平臺。用過Android手機的小夥伴們都知道一個不爭的事實,Androi

原创 Android事件處理模型

事件處理是Android編程中非常重要的一個部分,因爲Android應用在運行過程中會產生許多各種各樣的事件(動作),應用必須爲這些動作執行對應的響應代碼;將產生的動作和響應聯繫起來的方式就是事件處理機制。Android平臺提供了兩種事件

原创 [LeetCode]Binary Tree Maximum Path Sum

Binary Tree Maximum Path Sum  Given a binary tree, find the maximum path sum. The path may start and end at any node i

原创 [LeetCode]Longest Valid Parentheses

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parenthe

原创 [LeetCode] Surrounded Regions

Surrounded Regions Given a 2D board containing 'X' and 'O', capture all regions surrounded by'X'. A region is capture

原创 Android設計中的尺寸問題

Android把屏幕大小分成四種:small, normal, large, xlarge; 屏幕密度分成:low(ldpi), medium(mdpi), high(hdpi), extra high(xhdpi);各個屏幕密度之間的

原创 [LeetCode]Decode Ways

 A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... '

原创 [LeetCode] Sort List

Sort a linked list in O(n log n) time using constant space complexity. LeetCode: https://oj.leetcode.com/problems/sort-

原创 [LeetCode]Merge Intervals && Insert Interval

Merge Intervals Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,