自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

jasonkwan12的博客

我的博客

  • 博客(67)
  • 资源 (3)
  • 收藏
  • 关注

原创 字典树

推荐网站:https://songlee24.github.io/2015/05/09/prefix-tree/

2018-05-15 18:40:32 152

原创 第一个SpringBoot。

import org.springframework.web.bind.annotation.RestController;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;@RestContro...

2018-05-14 22:04:26 171

原创 LeetCode 35. Search Insert Position Java

Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.Exam...

2018-05-14 13:06:11 196

原创 Leetcode 34. Search for a Range Java

Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the tar...

2018-05-13 16:52:51 226

原创 LeetCode 152. Maximum Product Subarray Java

求最大连续子序列乘积! public int maxProduct(int[] nums) { int len=nums.length; int dp1[]=new int[len]; int dp2[]=new int[len]; dp1[0]=nums[0]; dp2[0]=nums[0]; for...

2018-05-13 16:20:33 174

原创 LeetCode 33. Search in Rotated Sorted Array

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 in t...

2018-05-08 23:28:24 104

原创 LeetCode 31. Next Permutation

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible ord...

2018-05-08 20:27:48 92

原创 LeetCode 29 Divide Two Integers

Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.Return the quotient after dividing dividend by divisor.The integer division should ...

2018-05-08 18:40:58 105

原创 LeetCode27 Remove Element

Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input array ...

2018-05-08 18:30:43 175

原创 简单实现一个死锁Java

class lock1 implements Runnable{ public void run(){ synchronized(Main.l1){ System.out.println("1:我获得了第一个锁"); try { Thread.sleep(3000); } catch (InterruptedEx...

2018-04-23 14:58:56 3503 3

原创 生产者/消费者问题的实现(JAVA)

1.阻塞队列class producer implements Runnable{ private final BlockingQueue sharedQueue; public producer(BlockingQueue sharedQueue){ this.sharedQueue=sharedQueue; } public void run()...

2018-04-23 14:51:45 203

原创 能放进hashmap的一个自定义类

public class HashTest{ private int i; public getInt(){ return i; } public void setI(int i){ this.i=i; } public boolean equals(Object object){ if(object=...

2018-04-21 12:13:25 760

原创 自定义comparator使用方法

升序import java.util.Arrays; import java.util.Comparator; public class Main { public static void main (String[] args) { Integer a[]={5,4,3,2,1}; Arrays.sort(a, new Co...

2018-04-20 15:12:08 1157

转载 最小的k个数(快速排序)

public ArrayList<Integer> GetLeastNumbers_Solution(int[] nums, int k) { if (k > nums.length || k <= 0) return new ArrayList<>(); int kthSmallest = findKthSmallest(nums, k - 1...

2018-04-20 13:59:23 467

原创 最小的k个数(堆实现)

用一个长度为K大根堆来维护这个最小的k个数。如果一个数比大根堆的堆顶小,说明它在最小的k个数里面。可以用Java的优先队列(底层是堆)设定优先级来实现! public ArrayList<Integer> GetLeastNumbers_Solution(int [] nums, int k) { if (k > nums.length || k <= 0)...

2018-04-20 13:45:32 530

原创 LeetCode 26. Remove Duplicates from Sorted Array

Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifying...

2018-04-18 13:18:26 143

原创 单例模式 (七种实现)

一、饿汉式O(线程安全):class MyObject{ private static MyObject object=new MyObject(); public static MyObject getobject(){ return object; }}二、懒汉式(线程不安全)class MyObject{ private static MyO...

2018-04-18 12:30:48 255

原创 排序算法Java实现

选择排序(升序): public static void sort(int[] a){ int N=a.length; for(int i=0;i<N;i++) { int min=i; for(int j=i+1;j<N;j++) { ...

2018-04-18 10:38:28 110

转载 网易nk数对

转载自https://blog.csdn.net/anlian523/article/details/79763170写的不错 我太菜了 哎一直都看不懂!题目描述:牛牛以前在老师那里得到了一个正整数数对(x, y), 牛牛忘记他们具体是多少了。但是牛牛记得老师告诉过他x和y均不大于n, 并且x除以y的余数大于等于k。牛牛希望你能帮他计算一共有多少个可能的数对。首先用两个for循环来暴力求解是可以得...

2018-04-16 22:42:21 207

原创 NIO利用通道来进行数据传输

/* * 一、通道:用于源节点与目标节点的连接.在Java NIO中负责缓冲区中的数据的传输。 * Channel本身不存储数据,需要配合缓冲区进行传输. * * 二、通道的主要实现类 * java.nio.channels.Channel接口: * FileChannel * //下面是用于网络的 * SocketChannel ...

2018-04-16 15:29:21 345

原创 LeetCode 数据库 175. Combine Two Tables

Table: Person+-------------+---------+| Column Name | Type |+-------------+---------+| PersonId | int || FirstName | varchar || LastName | varchar |+-------------+---------+Perso...

2018-04-16 12:53:11 165 1

原创 LeetCode 28. Implement strStr() Java

水题Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Example 2:Inpu...

2018-04-15 19:05:48 299

原创 初始NIO

/* * 1.缓冲区(Buffer):在Java NIO中负责数据的存取。缓冲区就是数组。 * 用于存储不同数据类型的数据 * * 根据数据类型不同(boolean 除外),提供了相应类型的缓冲区: * ByteBuffer * CharBuffer * ShortBuffer * IntBuffer * LongBuffer * FloatBuffer * DoubleB...

2018-04-14 21:42:18 88

原创 LeetCode 24. Swap Nodes in Pairs Java写法

Given a linked list, swap every two adjacent nodes and return its head.Example:Given 1->2->3->4, you should return the list as 2->1->4->3.Note:Your algorithm should use only constant...

2018-04-14 19:53:36 116

原创 mysql定时任务

查看定时任务是否开启:show variables like 'event_scheduler';开启定时任务:set global event_scheduler = on;定时更新ON COMPLETION [NOT] PRESERVE :表示当事件不会再发生的情况下,删除事件(注意特定时间执行的事件,如果设置了该参数,执行完毕后,事件将被删除,不想删除的话可以设置成ON COMPLETION...

2018-04-14 19:05:20 157

原创 大话同步IO,异步IO,阻塞IO,非阻塞IO区别

最近在刷题,看到这个问题,可能说的有错,但是轻喷!首先一个IO操作其实分成了两个步骤:发起IO请求和实际的IO操作,阻塞IO和非阻塞IO的区别在于第一步是否会阻塞!同步IO和异步IO的区别在于第二步!如果实际的IO读写阻塞请求进程,那么就是同步IO,因此阻塞IO、非阻塞IO、IO复用、信号驱动IO都是同步IO,如果不阻塞,而是操作系统帮你做完IO操作再将结果返回给你,那么就是异步IO。所以阻塞和非...

2018-04-14 16:24:00 188 3

转载 请写出你最常见到的5个runtime exception

RuntimeException是java中所有运行时异常的父类,实际运行时出现的都是它的子类,看看RuntimeException的Java doc就可以随便列出几个:1,Object x = new Integer(0); System.out.println((String)x);当试图将对象强制转换为不是实例的子类时,抛出该异常(ClassCastException)...

2018-04-13 13:04:35 1178

原创 LeetCode 23. Merge k Sorted Lists

Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.合并k个已排序的链表成一个排序链表(使用优先队列)class Solution { public ListNode mergeKLists(ListNode[] lists) { ...

2018-04-13 10:23:24 120

原创 Java优先队列使用

1,根据年龄小的先出优先级class Person implements Comparable<Person>{ public int age; Person(int age){ this.age=age; } public int compareTo(Person other){ return age-o...

2018-04-13 10:04:06 8221 1

原创 LeetCode 22. Generate Parentheses JAVA

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())", "...

2018-04-11 11:06:09 116

原创 LeetCode 19. Remove Nth Node From End of List JAVA删除链表倒数第N个

Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the en...

2018-04-10 19:37:45 98

原创 LeetCode18. 4Sum Java

Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note: The solution set m...

2018-04-10 00:17:17 268

转载 Java模拟并发访问

public class ConcurrentTest { public static void main(String[] args) { ExecutorService exec = Executors.newFixedThreadPool(30); for (int index = 0; index < 1000000; index++) { fin

2018-04-08 18:57:26 190

原创 LeetCode 17. Letter Combinations of a Phone Number IN JAVA

Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input:Digit string "23"...

2018-04-08 18:11:17 94

原创 mysql知识点

事务:1、属性:ACID原子性(Atomicity):事务是一个原子操作单元,其对数据的修改,要么全都执行,要么全都不执行。一致性(Consistent):在事务开始和完成时,数据都必须保持一致状态。这意味着所有相关的数据规则都必须应用于事务的修改,以保持数据的完整性;事务结束时,所有的内部数据结构(如B树索引或双向链表)也都必须是正确的。隔离性(Isolation):数据库系

2018-04-08 12:50:30 103

原创 mysql正则表达式学习

1,匹配任意一个字符SELECT prood_nameFROM productsWHERE pro_name REGEXP '.000'ORDER BY prod_name;返回 'csdn 5000' 'csdn 6000'这里使用了正则表达式.000。.是正则表达式一个字符,它表示匹配任意一个字符,因此,5000,6000都匹配且返回2,进行OR匹配SELECT prood_nameF...

2018-04-08 12:45:42 225

转载 正则表达式 匹配常用手机号

^1[3578]\d{9}$^1表示以1开头,[3578]表示第二位的数字为3578中的任意一个,\d{9}表示0~9范围内的数字匹配九次,$表示结束,12位以上的数字不匹配。

2018-04-07 21:59:05 937 1

转载 LeetCode-Number of Digit One

Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6, because digit 1 occurred in the following number...

2018-04-07 20:51:27 108

原创 LeetCode 16. 3Sum Closest

Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly...

2018-04-07 16:44:31 83

原创 LeetCode 15. 3Sum

Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain dupli...

2018-04-07 16:23:25 69

log4j-1.2.17.jar csdn下载

log4j-1.2.17.jar csdn下载 超级好用 实测完美 !!!!

2018-02-09

mysql安装版win64

mysql安装版win64 msi的。。。。。。。。。。。。。。。。。。。。。

2018-02-04

j2ee 1.5 API+j2se6.0+java_API_1.7中文

j2ee 1.5 API+j2se6.0+java_API_1.7中文,网上找了很久

2018-02-03

空空如也

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

TA关注的人

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