- 博客(34)
- 资源 (11)
- 问答 (1)
- 收藏
- 关注
原创 LeetCode 209. Minimum Size Subarray Sum--从数组中查找某个最短子段的和大于等于s时,返回子段的长度,反之返回0
Given an array of n positive integers and a positive integer s, find the minimal length of a contiguous subarray of which the sum ≥ s. If there isn't one, return 0 instead.Example: Input: s = 7, ...
2018-11-27 23:34:24 1031
原创 LeetCode 189. Rotate Array-按照给定K,把末尾元素放在前面,旋转一个数组
189.Rotate ArrayGiven an array, rotate the array to the right byksteps, wherekis non-negative.Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotate 1 steps...
2018-11-26 22:14:31 235
原创 LeetCode 33. Search in Rotated Sorted Array-一个原来有序的数组从中间某个元素旋转,查找某个元素是否存在,存在返回下标,反之返回-1
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).You are given a target value to search. If found ...
2018-11-25 22:09:43 633
原创 二分查找-存在则返回下标,反之则返回-1(2018)
/** * 存在则返回下标,反之则返回-1 * @param arr * @param target * @return */ public int binarySearch(int[] arr, int target) { int low = 0; int high = arr.length...
2018-11-25 21:51:10 261
原创 LeetCode 78. Subsets--输出一个一维数组的所有子集(元素不重复),递归和非递归实现
Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[ [3], [1...
2018-11-23 23:31:46 1309
原创 Tomcat8点击start不启动,点击startup.bat闪退
方法1:把jvm换成java即可方法2:网上说的在startup.bat末尾添加PAUSE或pause阻止闪退看原因,不可行,我试了,依旧会闪退还有在开头添加 SET JAVA_HOME等等,不可行,我试了,依旧会闪退 我用的printscreen,抓屏,看日志,判断错误,如果是端口被占用,可以自行更改。当然也有更好的方法。我的:Win7 64位,jdk1.8.131...
2018-11-21 22:30:11 2811 1
原创 Tomcat8启动错误JRE_HOME environment variable is not defined correctly
解决办法:右击 我的电脑 - 高级 - 环境变量, 在系统变量中 新建 变量名:JRE_HOME 变量值:C:\Program Files\Java\jdk1.8.0_131(根据自己的) 我的:Win7 64位,jdk1.8.131 64位...
2018-11-21 22:26:05 1201
原创 java如何判断二维数组为空
int[][] matrix = new int[][]{{}};//matrix.length表示行数,matrix[0].length表示第一行的列数 System.out.println(matrix == null);//false System.out.println("--"); System.out.print...
2018-11-21 22:21:31 1388
原创 LeetCode 74. Search a 2D Matrix--二维数组 每行有序,且当前行的首元素大于上一行的末位元素,判断是否存在某元素
74.Search a 2D MatrixMediumWrite an efficient algorithm that searches for a value in anmxnmatrix. This matrix has the following properties:Integers in each row are sorted from left to right...
2018-11-21 22:12:42 386
原创 IDEA集成Tomcat之后的日志路径
C:\Users\姓名拼音\.IntelliJIdea2018.1\system\tomcat\Unnamed_weather-expert_2\logsSpringBoot自带Tomcat的日志路径暂不知道
2018-11-21 15:10:33 5672
原创 LeetCode 64. Minimum Path Sum--从左上角到右下角的路径经过的元素和最小是多少,每次只能往右或往下移动一步
64.Minimum Path SumGiven amxngrid filled with non-negative numbers, find a path from top left to bottom right whichminimizesthe sum of all numbers along its path.Note:You can only move eit...
2018-11-19 22:45:38 816
原创 LeetCode 63. Unique Paths II--二维数组从左上角到右下角的唯一路径的种数有多少,有1的位置不能走,只能向右或向下移动--2D DP
A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bo...
2018-11-18 18:49:59 917
原创 LeetCode 62. Unique Paths--二维数组从左上角到右下角的唯一路径的种数有多少,只能向右或向下移动--DP
A robot is located at the top-left corner of amxngrid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bo...
2018-11-18 17:32:53 1256
原创 LeetCode 54. Spiral Matrix--给定一个n*m的二位数组,顺时针打印出元素,如果没有元素,打印出[]
Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7,4,5]...
2018-11-18 16:20:27 300
原创 LeetCode 59. Spiral Matrix II--输入一个正整数,顺时针打印从1到n^2组成二维数组
59.Spiral Matrix IIGiven a positive integern, generate a square matrix filled with elements from 1 ton^2in spiral order.Example:Input: 3Output:[ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ]]...
2018-11-18 12:33:43 610
原创 Function,BiFucntion,Supplier理解与实例 三
这是表中的数据:Weather.xml: <select id="queryString" resultType="java.lang.String" parameterType="java.lang.String"> select area_name from weather_table where cur_weather is null and pr...
2018-11-16 21:01:04 1024
原创 Comparator泛型排序方法,适用于多种类型,函数式编程
import com.alibaba.fastjson.JSON;import java.util.ArrayList;import java.util.Comparator;import java.util.List;import java.util.stream.Collectors;/** * @Desc **/public class ComparatorT {...
2018-11-16 20:23:35 1937
原创 Function,BiFucntion理解与实例 二
import java.util.function.BiFunction;/** * @Desc **/public class FunctionTest { public static void main(String[] args) { FunctionTest functionTest = new FunctionTest(); f...
2018-11-15 21:24:58 475
原创 LeetCode 45. Jump Game II--当前元素值表示能跳跃的最大长度,求跳跃到最后一个元素的最少跳跃次数--贪心算法
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to...
2018-11-13 22:44:00 741
原创 LeetCode 55. Jump Game--从第一个元素开始往后跳,每个元素的值表示可跳跃的最大长度,如果能跳跃到最后的元素则返回true--贪心算法【从前往后复杂,就从后往前】
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if yo...
2018-11-12 22:16:47 564
原创 @Configuration,@Autowired ExecutorService 不必重复初始化线程池
不必每次都重新写一遍线程池初始化的代码,只需要@Autowired ExecutorService 即可。import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.ste...
2018-11-12 20:19:39 2706
原创 CountDownLatch与线程池共用,主线程等待多个子线程执行完再继续执行
public class CollectionSyn { public static void main(String[] args) { CollectionSyn collectionSyn = new CollectionSyn(); //1 //collectionSyn.f1(); //2 /* ...
2018-11-12 20:06:20 1709
原创 Collections.synchronizedList实例
// 不是org.apache.commons.collections.CollectionUtils,是java自带的java.util.Collections// List<String> list = Collections.synchronizedCollection(new ArrayList<String>());//报错// List&...
2018-11-12 19:58:31 702
原创 ScheduledThreadPool,schedule,scheduleAtFixedRate,scheduleWithFixedDelay 实例
public class ScheduledThreadPoolTest { public static final SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); public static void main(String[] args) { ScheduledThreadPoolT...
2018-11-10 16:36:15 888
原创 DecimalFormat格式化小数0,#
public static final DecimalFormat DFORMAT1 = new DecimalFormat("0.00");//小数位多于2位时四舍五入,最多保留两位小数,第二位是0也保留,如果是整数末位有2个0 public static final DecimalFormat DFORMAT2 = new DecimalFormat("0.0#");//小...
2018-11-10 10:06:10 6909
原创 接口、抽象类区别与总结
继承抽象类:public abstract class Test1Abstract { private Integer a; static { System.out.println(123); } public void f1() { } public abstract void abstractf1();//抽象...
2018-11-09 11:42:37 325
原创 线程池.invokeAll,invokeAny实例
invokeAll触发执行任务列表,返回的结果顺序也与任务在任务列表中的顺序一致.所有线程执行完任务后才返回结果。如果设置了超时时间,未超时完成则正常返回结果,如果超时未完成则报异常。invokeAny将第一个得到的结果作为返回值,然后立刻终止所有的线程。如果设置了超时时间,未超时完成则正常返回结果,如果超时未完成则报超时异常。1 //自定义的类 class Resul...
2018-11-07 22:24:03 2906
原创 StringUtils.join,原集合为空,结果不为空
import org.apache.commons.collections.CollectionUtils;import org.apache.commons.lang.StringUtils;import java.util.ArrayList;import java.util.List;/** * @Desc **/public class Test8 { p...
2018-11-07 21:24:40 2267
原创 java基本类型做函数参数
Char,Byte,Short,Integer,Double,Float,Long,Boolean及对应的char,byte,short,integer,double,float,long,boolean和String类型,作为参数传入函数时,如果不返回,则原值不会改变,只有返回后,原值才会改变。自定义类、现存类、数组(无论元素是否是基本类)、List作为参数传入函数时,无论是否返回,原值均会...
2018-11-06 21:13:22 766
原创 FixedThreadPool,submit,execute,Callable,Runnable实例
一般使用线程池执行任务都是调用的execute方法,这个方法定义在Executor接口中:public interface Executor { void execute(Runnable command);}这个方法是没有返回值的,而且只接受Runnable。那么像得到线程的返回值怎嘛办呢?在ExecutorService接口中能找到这个方法:<T> Fu...
2018-11-06 19:58:38 916
原创 ThreadPoolExecutor的四种抛弃策略
常规情况下: ThreadPoolExecutor tpe = new ThreadPoolExecutor(2, 3, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(5), new ThreadPoolExecutor.AbortPolicy()); //任务8,...
2018-11-06 18:28:15 2077
原创 PostMapping,GetMapping访问多个路径,报错500解决
PostMapping中的value属性是数组,所以可以定义多个路径,required属性默认是true,不必再写required=true,默认表示该参数是必须要有的,如果写required=false,表示该参数是可选的,可有可无。1: @PostMapping("/queryCurWeatherNullById/{id}/{name}") @Override ...
2018-11-02 18:43:53 18837 2
mhd raw metaimage java读取类
2017-10-18
commons-lang-2.5.jar
2016-07-08
commons-configuration-1.6.jar
2016-07-08
android通过servlet与服务器验证用户信息
2016-03-26
全国省市县区域名称
2015-11-17
android布局中用到dimension,这样的作用是什么?好处是?
2015-12-26
TA创建的收藏夹 TA关注的收藏夹
TA关注的人