- 博客(14)
- 资源 (11)
- 问答 (1)
- 收藏
- 关注
原创 ImageView嵌套进ScrollView,发现图片总是存在间隔
解决方案,将imageView的下面属性设置为true即可android:adjustViewBounds="true" <ScrollView android:layout_width="match_parent" android:padding="0dp" android:layout_margin="0dp"
2017-08-25 11:03:47 1036
原创 322. Coin Change
class Solution { public int coinChange(int[] coins, int amount) { int max = amount + 1; // 最小的币值为1,就算全部用1,硬币个数也不会超过amount + 1 int d[] = new int[amount+1]; Ar
2017-08-20 21:07:45 269
原创 198. House Robber
public class Solution { public static int[] result; public int solve(int idx,int[] nums){ if(idx < 0){ return 0; } if(result[idx] >=0 ){ return
2017-08-17 23:03:38 258
原创 94. Binary Tree Inorder Traversal
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution {
2017-08-13 18:22:54 250
原创 144. Binary Tree Preorder Traversal
/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution {
2017-08-13 18:18:38 226
原创 101. Symmetric Tree
1.100题的变形/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class S
2017-08-13 16:51:43 234
原创 100. Same Tree
public class Solution { public boolean isSameTree(TreeNode p, TreeNode q) { if(p == null && q == null) return true; if(p!= null && q !=null && p.val == q.val){ re
2017-08-13 16:44:51 233
原创 124. Binary Tree Maximum Path Sum
1.定义maxDeep(x)为以x为根节点的树的max path maxDeep(x)等于在下面a,b,c中找到一个最大的值,c的话是因为左子树的max path 和 右子树的max path可能值为负 a.左子树的max path + x自身的值 b.右子树的max path + x自身的值 c.x自身的值/** * Definition for
2017-08-07 11:25:22 256
原创 112. Path Sum
1.递归搜索树/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Sol
2017-08-07 09:37:56 252
原创 50. Pow(x, n)
1.换底公式public class Solution { public double myPow(double x, int n) { int sign = 1; if( x < 0 && n % 2 == 1){ sign = -1; } x = Math.abs(x); ret
2017-08-06 17:40:55 516
原创 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(int i = 0; i < n; i++){ int L = 0; int R = n-1;
2017-08-05 23:26:27 211
原创 69. Sqrt(x)
1.二分法解题,最恶心的就是边界问题,为了边界问题基本上都得调试一段时间 注意,当 x 为 int 时,相乘会越界(大于int的最大数2147483647) ,所以用 相除 代替 相乘public class Solution { public int mySqrt(int x) { if(x<=1) return x; int left =
2017-08-03 09:42:14 249
原创 202. Happy Number
1.题目说的是对任意一个正整数,不断各个数位上数字的平方和,若最终收敛为1,则该数字为happy number,否则程序可能从某个数开始陷入循环。这里我们使用一个HashSet表存储已经出现过的数字,如果下次还出现,则返回false。public class Solution { public boolean isHappy(int n) { Set set = n
2017-08-02 09:53:10 202
原创 292. Nim Game
1.此类问题为一类问题,记住即可,若1次最多可取k个(k在问题中是看作常量),记f(n)代表自己先拿,总共有n块石头时,自己是必输还是必胜。 当 n % (k+1) == 0 时,代表自己必胜比如 k = 4 时,代表一次性可拿 1块,2块,3块,4块石头,而f(1)代表桌上总共有1块石头可拿,自己先拿的情况下,是必输还是必胜? 可以知道,f(1),桌上石头只有1块,而自己可
2017-08-01 16:38:09 200
PullZoomView 支持ScollView和ListView的上方View随下拉放大效果
2015-08-03
利用wx.uploadFile上传图片,名字乱码
2019-05-20
TA创建的收藏夹 TA关注的收藏夹
TA关注的人