- 博客(35)
- 收藏
- 关注
原创 LeetCode 371. Sum of Two Integers
原题: Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example: Given a = 1 and b = 2, return 3.题意: 计算两个整数a和b的和,但是你不允许使用操作符+和-。例子: 给定a=1和b=2,返回3。思路: 利用两
2017-02-03 13:21:54
410
原创 LeetCode 136. Single Number(Java)
原题: Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using ext
2017-01-25 15:56:43
462
原创 LeetCode 492. Construct the Rectangle(Java)
原题: For a web developer, it is very important to know how to design a web page’s size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose leng
2017-01-23 23:02:14
1298
原创 LeetCode 448. Find All Numbers Disappeared in an Array(Java)
原题: Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Coul
2017-01-23 22:38:15
724
原创 LeetCode 292. Nim Game(Java)
原题: You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be
2017-01-22 21:34:38
437
原创 LeetCode 463. Island Perimeter(Java)
原题: You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is complet
2017-01-21 11:52:02
1075
原创 LeetCode 344. Reverse String(Java)
原题: Write a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.题意: 写一个方法可以将输入的字符串反转并返回。思路: 1.将字符串转化为字符数组; 2.对字符数组关于中间对称的元素进行交换; 3.将字符
2017-01-19 22:25:44
434
原创 LeetCode 412. Fizz Buzz(Java)
原题: Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”.
2017-01-19 22:13:57
1006
原创 LeetCode 485. Max Consecutive Ones(Java)
原题: Given a binary array, find the maximum number of consecutive 1s in this array.Example 1: Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutiv
2017-01-19 21:45:33
998
原创 LeetCode 476. Number Complement(Java)
原题: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation.Note: The given integer is guaranteed to fit within the range of a
2017-01-19 21:20:34
858
原创 LeetCode 2. Add Two Numbers(Java)
原题: You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and retu
2017-01-14 23:33:58
481
原创 LeetCode 1. Two Sum(Java)
原题: Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution.Example: Given nums = [2, 7
2017-01-13 23:07:44
294
原创 LeetCode 461. Hamming Distance(Java)
原题: The Hamming distance between two integers is the number of positions at which the corresponding bits are different.Given two integers x and y, calculate the Hamming distance.Note: 0 ≤ x, y < 231.
2017-01-07 08:12:52
601
原创 LeetCode 350. Intersection of Two Arrays II(Java)
原题: Given two arrays, write a function to compute their intersection.Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2].Note: Each element in the result should appear as many times a
2016-12-07 23:59:30
413
原创 LeetCode 217. Contains Duplicate(Java)
原题: Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every elemen
2016-12-07 23:25:32
356
原创 LeetCode 409. Longest Palindrome(Java)
题目: Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example “Aa” is not con
2016-12-06 20:12:38
301
原创 LeetCode 169. Majority Element(Java)
题目: Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority element al
2016-12-06 19:30:19
405
原创 单例模式(懒汉模式与饿汉模式)
1.单例模式: 应用场景:当系统中只需要一个对象就够了,如任务管理器、古代皇帝、现代老婆 作用:保证在一个系统中有且只有一个实例 类型:饿汉模式、懒汉模式2.饿汉模式:public class Singleton { //1.私有化构造方法,让其他类无法通过new的方式创建该类的实例 private Singleton(){ } //2.创建类的唯一实例,使用pr
2016-10-20 15:33:21
400
原创 Tomcat Jboss Apache WebLogic区别与比较
1.Tomcat是Apache鼎力支持的Java Web应用服务器,由于它优秀的稳定性以及丰富的文档资料,广泛的使用人群,从而在开源领域受到最广泛的青睐。实际上Tomcat 部分是Apache 服务 器的扩展,但它是独立运行的,所以当你运行tomcat 时,它实际上作为一个与Apache 独立的进 程单独运行的。2.Apache全球应用最广泛的http服务器,免费,出自apache基金组织.apa
2016-10-18 17:35:23
554
转载 Java的四种引用,强弱软虚,用到的场景
java中的4种reference的差别和使用场景(含理论.代码和执行结果)我们知道Java语言提供了4种引用类型:强引用、软引用(SoftReference)、弱引用(WeakReference)和幽灵引用(PhantomReference),与引用密切相关的,还有一个引用队列ReferenceQueue。引用和引用队列的关系,对于垃圾回收来说非常重要,学习垃圾回收机制,必须要先了解引用和引用队列
2016-10-18 17:14:56
770
原创 switch能否用String做参数?
在Java7之前,switch只支持byte、short、char、int或者其对应的包装器类以及枚举类型作为参数;但是,自从Java7开始,也支持String类型作为参数。
2016-09-30 16:32:38
393
原创 String,StringBuffer, StringBuilder 的区别
(1)执行速度(操作)比较:StringBuilder>StringBuffer>String。 (2)StringBuffer是线程安全的,StringBuilder是线程不安全的。 (3)如果要操作少量的数据,则选择用String; 在单线程操作字符串缓冲区下操作大量数据,则用StringBuilder; 在多线程操作字符串缓冲区下操作大量数据
2016-09-30 16:28:21
339
原创 Spring入门之关于IOC和DI的大致启动流程
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl
2016-05-08 23:05:45
930
原创 Spring初学之Bean标签中的abstract和parent属性
1.在bean中配置abstract属性为”true”,则spring容器不会为该类创建对象。<bean id="person" class="spring.extend.Person" abstract="true"> <property name="name" value="张三"></property> </bean> 2.在bean中配置parent属性,则可以让
2016-05-03 14:45:46
7550
原创 Spring入门之初学注解03(@Controller、@Service、@Repository)
用注解书写mvc模式1.新建PersonDao.javapublic interface PersonDao { public void savePerson();}2.新建PersonService.javapublic interface PersonService { public void savePerson();}3.新建PersonDaoImpl.java@Repo
2016-05-03 11:12:51
541
原创 Spring入门之初学注解02
1.新建Student.java@Componentpublic class Student { public void say(){ System.out.println("Student"); }}2.新建Person.java@Componentpublic class Person { @Resource(name="student")
2016-05-03 00:24:00
337
原创 Spring入门之初学注解01
1.新建Student.javapublic class Student { public void say(){ System.out.println("Student"); }}2.新建Person.javapublic class Person { @Resource(name="student")// @Autowired //按照类型进行匹配
2016-05-03 00:19:13
360
原创 Spring入门之IOC与DI个人总结
1.Spring框架通过IOC创建、配置以及销毁Bean,实现对Bean的管理。 2.Spring框架通过DI对Bean属性的赋值以及配置等进行操作。
2016-05-02 20:52:41
394
原创 Spring入门之依赖注入(DI)
Spring依赖注入的方式有两种,分别是构造器依赖注入和set方法依赖注入。第一种方式(构造器): 1.新建Student.javapublic class Student { public void say(){ System.out.println("say"); }}2.新建Person.javapublic class Person { priva
2016-05-02 20:47:18
438
原创 Spring入门之bean的属性
可以在bean中配置scope属性,例如:<bean xxx lazy-init="false"></bean>在默认情况下,spring创建bean是单例模式 scope默认是singleton: singleton:单例 * 属性是共享的 * 一般情况下,把数据存放到
2016-04-28 12:09:57
429
原创 Spring入门之创建Bean的时间以及lazy-init属性
1.在默认情况下,在启动spring容器时,spring容器配置文件中的类就已经创建完成对象了。2.可以在applicationContext.xml配置文件中<bean></bean>标签中配置属性lazy-init3.默认情况下lazy-init为default。4.lazy-init可以设置为true或false。当设置为true时,在context.getBean()时才创建对象;当设置为f
2016-04-28 00:29:13
1136
原创 Spring入门之实例化Bean的三种方式
1.构造方法实例化 HelloWorld.java(Bean类)public class HelloWorld { public HelloWorld(){ System.out.println("HelloWorld构造函数"); } public void hello(){ System.out.println("hello world");
2016-04-27 12:22:24
375
原创 Spring入门之HelloWorld
1.新建java项目 Spring2.导入jar包 2.1 到http://www.springsource.org/download下载spring,然后进行 解压缩,在解压目录中找到下面jar文件,拷贝到类路径下 2.2 spring的核心类库 在spring文档的dist下 dist\spring.jar 2.3 引入的第三方类库 都spring文档的lib下lib\jakar
2016-04-27 01:08:33
292
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人