自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(60)
  • 资源 (1)
  • 收藏
  • 关注

转载 spring多环境配置

我们在开发Spring Boot应⽤时, 通常同⼀套程序会被应⽤和安装到⼏个不同的环境, ⽐如: 开发、 测试、 ⽣产等。 其中每个环境的数据库地址、 服务器端⼝等等配置都会不同, 如果在为不同环境打包时都要频繁修改配置⽂件的话, 那必将是个⾮常繁琐且容易发⽣错误的事。对于多环境的配置, 各种项⽬构建⼯具或是框架的基本思路是⼀致的, 通过配置多份不同环境的配置⽂件, 再通过打包命令指定...

2019-12-02 15:11:05 210 1

原创 java8 lambda表达式

Integer[] a ={1,2,3,4}; List<List<Integer>> list = new ArrayList<>(); for (int i = 0; i < 5; i++) { list.add(new ArrayList<Integer>(Arrays.asLis...

2019-09-24 11:03:03 152

原创 java二维list按指定index排序

list.sort(Comparator.comparing((List<Integer> a)->a.get(0)));使用内联,重写Comparator的compare方法,但在java8之后,推荐使用上面的lambda表达式。Collections.sort(list, new Comparator<List<Integer>&gt...

2019-09-23 21:10:44 1472

原创 leetcode 114

/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */class Solution { pub...

2019-06-29 20:06:10 121

原创 leetcode 48

class Solution { public void rotate(int[][] matrix) { int n = matrix.length; for(int i=0; i<n/2; i++){ for(int j=i; j<n-i-1; j++){ int t = matrix...

2019-06-13 21:36:23 115

原创 leetcode 39

class Solution { List<List<Integer>> list = new ArrayList<>(); public List<List<Integer>> combinationSum(int[] candidates, int target) { Arrays.sort(cand...

2019-06-12 11:31:46 102

原创 leetcode 11

class Solution { public int maxArea(int[] height) { int max = 0; for(int i=0; i<height.length; i++){ for(int j=i+1; j<height.length; j++){ max = ...

2019-06-03 15:52:46 90

原创 leetcode 6

class Solution { public String convert(String S, int n) { List<List<Character>> list = new ArrayList<>(); if(n==1||n>=S.length())return S; for (...

2019-06-03 14:44:05 92

原创 leetcode 5

class Solution { public String longestPalindrome(String s) { if(null == s || s.length()<=1) return s; int begin = 0, len = s.length(); int longlen = 1; ...

2019-06-02 22:31:18 97

原创 leetcode 81

从今天开始刷中等难度的题目了,第一道就这么给力?自己写半天的二分查找,还不如直接暴力。也是,想要分部二分,也要遍历,还不如直接全遍历了。懒得写函数了,就直接复制粘贴。class Solution { public boolean search(int[] nums, int target) { for(int i:nums){ if(i==ta...

2019-05-31 21:22:02 111

原创 leetcode 429

算是List的一个妙用?没有get方法的话,应该是没法做到,之前忘记了这个用法。class Solution { List<List<Integer>> list = new ArrayList<>(); public List<List<Integer>> levelOrder(Node root) { ...

2019-05-28 21:17:40 124

原创 leetcode 942

class Solution { public int[] diStringMatch(String S) { int len = S.length(); char[] s = S.toCharArray(); int[] res = new int[len+1]; for(int i=len-1; i>=0; i--...

2019-05-28 16:12:10 125

原创 leetcode 438

class Solution { public List<Integer> findAnagrams(String s, String p) { List<Integer>list = new ArrayList<>(); int[] ret = new int[26]; int slen = s.len...

2019-05-28 10:20:46 95

原创 leetcode 400

class Solution { public int findNthDigit(int n) { int[] field = {9,189,2889,38889,488889,5888889,68888889,788888889}; if(n<10)return n; int t= 0; for(int i:fiel...

2019-05-27 11:16:51 178

原创 leetcode 437

class Solution { int count; public int pathSum(TreeNode root, int sum) { if(root==null)return 0; pre(root,0,sum); pathSum(root.left,sum); pathSum(root.right,su...

2019-05-27 10:01:49 118

原创 leetcode 1030

class Solution { public int[][] allCellsDistOrder(int R, int C, int r0, int c0) { int[][] res = new int[R*C][2]; int count = 0; for(int i = 0; i < R; i++){ ...

2019-05-22 20:53:35 192

原创 leetcode 893

class Solution { public int numSpecialEquivGroups(String[] A) { Set<String> set = new HashSet<>(); for(int i = 0; i < A.length; i++){ int[] t = new int[...

2019-05-22 18:59:28 206

原创 leetcode 404

class Solution { int sum; public int sumOfLeftLeaves(TreeNode root) { if(root==null)return 0; solve(root,false); return sum; } public void solve(TreeNode root,...

2019-05-21 11:29:10 179

原创 leetcode 892

class Solution { public int surfaceArea(int[][] grid) { int len = grid.length; int surface1 = 0, surface2 = 0; for(int i=0; i<len; i++){ for(int j=0; j<l...

2019-05-21 11:19:14 283

原创 leetcode 766

转换思路,判断该行除最后一个数与下一行除第一个数是否完全一致。class Solution { public boolean isToeplitzMatrix(int[][] matrix) { int r = matrix.length, c = matrix[0].length; for(int i=0; i < r-1; i++){ ...

2019-05-21 10:57:08 128

原创 leetcode 1022

能写对一次递归不容易啊????总是写不对递归,只能写最简单的。。。。。。。。。。class Solution { int sum; public int sumRootToLeaf(TreeNode root) { sum=0; String s = ""; solve(root,s); return sum...

2019-05-20 21:25:07 165

原创 leetcode 1029

思路比较好,通过计算每一个一维数组的差值,将结果保存在另一个一维数组,对差值进行排序,然后将差值的前n/2加在累加结果中,相当于+另一个值。该题目的目的就在于按大小添加去A地和去B地差值。class Solution { public int twoCitySchedCost(int[][] costs) { int len = costs.length, cos...

2019-05-20 20:52:52 225

原创 leetcode 949

class Solution { public String largestTimeFromDigits(int[] A) { Arrays.sort(A); for(int i=3; i >=0; i--){ if(A[i]>2)continue; for(int j=3; j>= 0; ...

2019-05-06 19:48:54 154

原创 leetcode 796

class Solution { public boolean rotateString(String A, String B) { int lenA = A.length(); int lenB = B.length(); return (lenA==lenB)&&((A+A).contains(B)); }}...

2019-04-29 16:22:49 119

原创 leetcode 746

动态规划,从后向前,比较是先走一步比较省力还是走两步比较省力,取最小值,最后比较cost[0]和cost[1],取最小值。class Solution { public int minCostClimbingStairs(int[] cost) { int len = cost.length; for(int i = len-3; i >= 0;...

2019-04-25 21:38:56 194

原创 leetcode 703

class KthLargest { int n; PriorityQueue<Integer> q; public KthLargest(int k, int[] nums) { n = k; q = new PriorityQueue<Integer>(n); for(int i : nums){...

2019-04-23 20:48:02 152

原创 leetcode 669

class Solution { public TreeNode trimBST(TreeNode root, int L, int R) { if(root==null)return root; if(root.val<L){ return trimBST(root.right,L,R); }else if(...

2019-04-22 21:31:00 144

原创 leetcode 606

右子树为空时可以省略括号。class Solution { public String tree2str(TreeNode t) { if(t!=null){ if(t.left==null&&t.right==null) return t.val+""; return t...

2019-04-19 15:21:30 176

原创 leetcode 599

class Solution { public String[] findRestaurant(String[] list1, String[] list2) { int min = 0x7fffffff; int len1 = list1.length, len2 = list2.length; ArrayList<String&g...

2019-04-18 20:17:28 160

原创 leetcode 572

遍历二叉树s的每个节点,将节点与 t 树使用递归进行比较,实际是二叉树递归遍历的考察。最近发现经常在递归的遍历应用时有点困难,不知道如何递归遍历,以及在递归中,结果的处理和输出位置。对于递归的掌握需要加强。class Solution { public boolean isSubtree(TreeNode s, TreeNode t) { if(s==null...

2019-04-16 20:43:31 160

原创 leetcode 453

逆向思维,将加(n-1)个数的值转化为减一个数的值,也就是最后大家都是和最小值一样。class Solution { public int minMoves(int[] nums) { int sum = 0,min = min(nums); for(int i:nums) { sum+=i-min; ...

2019-04-09 15:23:24 154

原创 leetcode 415

字符串加法。该方法适用其他的类似加法,比如链表加法,二进制加法等。class Solution { public String addStrings(String num1, String num2) { StringBuilder sb = new StringBuilder(); int carry = 0, i = num1.length()-1...

2019-04-02 16:09:20 155

原创 leetcode 371

不使用加减运算符实现计算两数之和。使用异或运算符可以得到无进位的两数之和,1^1=0 1^0=1 0^0=0使用与运算符可以的到进位和,1&1=1 1&0=0 0&0=0class Solution { public int getSum(int a, int b) { int res=0; int sum=a^b; int f=(a&am...

2019-03-27 20:57:02 221

原创 leetcode 367

注意数据类型,int or longclass Solution { public boolean isPerfectSquare(int num) { long l = 0, h = num; while(l<=h){ long m = l + (h - l)/2; if(m*m==num)ret...

2019-03-27 20:42:10 140

原创 leetcode219 存在重复元素II

存在两个相同元素的距离小于等于k值,使用字典存储第一个遇到的下标,若遇到了相同值,且距离不大于k,则返回true,否则更新字典中的下标值,因为之后如果再遇到相同值,肯定是当前值离得更近,因此需要对字典进行更新。class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { Map...

2019-03-25 21:35:14 116

原创 leetcode198 打家劫舍

动态规划的题目,新建另一个数组memo用来保存从 i 到 数组末尾能取到的最大值,直到memo[0]分别比较取 i 或者不取 i 而取 i+1 时候的值,进行选择class Solution { public int rob(int[] nums) { int length = nums.length; if(length == 0)return ...

2019-03-19 09:30:06 103

原创 leetcode160 相交链表

大佬的思路很好,是通过两个指针分别遍历相同的距离实现找到第一个相同节点。遍历两次,第一次用来消除长度差异,第二次找到相同点。public class Solution { public ListNode getIntersectionNode(ListNode headA, ListNode headB) { ListNode p,q; p = ...

2019-03-14 10:58:22 89

原创 leetcode 112 路径总和

class Solution { public boolean hasPathSum(TreeNode root, int sum) { if(root==null)return false; int remain = sum - root.val; if(remain==0&amp;&amp;root.left==null&amp;&am...

2019-03-11 21:31:05 105

原创 leetcode 70 爬楼梯

这个题应该是用动态规划做吧,暂时还没有接触。我想到的方法是分别处理有1,2,3等个2阶的时候,用C(I,N),也就是数学上的组合来解决。这个方法是参考的别人的解法class Solution { public int climbStairs(int n) { int res1 =1, res2 = 2,res = 0; if(n==1)ret...

2019-03-07 22:53:52 70

原创 leetcode 67 二进制求和

不多写了,准备每天至少刷一道算法题,刚开始用java刷算法,感觉菜的不行,需要读读别人的代码学习。String a = "111"; String b = "1"; String l = null, s = null; int llength = 0, slength = 0; if (a.length() &gt; b.len...

2019-03-07 21:50:47 82

Mybatis3中文文档

mybatis3官方中文文档,内含多个pdf高清文档,总会帮助到你

2018-10-18

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除