原创 base target="_blank"的用處

<base target="_blank"/>的用處1.定義頁面中所有鏈接的打開方式,此時多個a標籤中的target屬性可以省略了。

原创 前端外邊距(margin)的問題

1.上下外邊距會疊壓2.父子級包含的時候,子級的margin-top會傳遞給父級。3.設置  margin-left:auto 時,此時 元素會緊緊的靠在 右側4.設置  margin-right:auto 時,此時 元素會緊緊的靠在 左

原创 69. Sqrt(x)

1.二分法解題,最噁心的就是邊界問題,爲了邊界問題基本上都得調試一段時間   注意,當 x 爲 int 時,相乘會越界(大於int的最大數2147483647) ,所以用 相除 代替 相乘 public class Solution {

原创 ImageView嵌套進ScrollView,發現圖片總是存在間隔

解決方案,將imageView的下面屬性設置爲true即可 android:adjustViewBounds="true" <ScrollView android:layout_width="match_pare

原创 198. House Robber

1.遞歸 public class Solution { public static int[] result; public int solve(int idx,int[] nums){ if(idx <

原创 207. Course Schedule

class Solution { public boolean canFinish(int numCourses, int[][] prerequisites) { // 初始化鄰接表 List<

原创 112. Path Sum

1.遞歸搜索樹 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; *

原创 378. Kth Smallest Element in a Sorted Matrix

public class Solution { public boolean guess(int g,int[][] matrix, int k, int n){ int sum = 0; for(

原创 94. Binary Tree Inorder Traversal

/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeN

原创 50. Pow(x, n)

1.換底公式 public class Solution { public double myPow(double x, int n) { int sign = 1; if( x < 0 && n

原创 258. Add Digits

1.傳統方法 public class Solution { public int addDigits(int num) { int ans = 0; if(num<10) return num;

原创 144. Binary Tree Preorder Traversal

/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeN

原创 public class Solution { public int countPrimes(int n) { boolean[] isDelArray = new boolean[n];

1.注意邊界條件 public class Solution { public int countPrimes(int n) { boolean[] isDelArray = new boolean[n]; if (n <=

原创 124. Binary Tree Maximum Path Sum

1.定義maxDeep(x)爲以x爲根節點的樹的max path    maxDeep(x)等於在下面a,b,c中找到一個最大的值,c的話是因爲左子樹的max path 和 右子樹的max path可能值爲負    a.左子樹的max p

原创 268. Missing Number

1.原數列origin_array 的和  減去  少了一個數字的數列sub_array的和,注意原數列是0 1 2 3 - - - n的n+1個數字,比少了一個數字的數列的長度多1。 public class Solution {