- 博客(95)
- 资源 (1)
- 收藏
- 关注
转载 Java单例详解
本文转载自以下两篇singleton模式四种线程安全的实现 http://www.importnew.com/18774.html如何防止单例模式被JAVA反射攻击 http://geek.youkuaiyun.com/news/detail/126382singleton模式四种线程安全的实现1.描述 Singleton(单
2016-12-15 15:53:26
460
原创 [leetcode]28. Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.java代码public class Solution { public int strStr(String
2016-12-08 18:11:11
362
原创 [leetcode]26. Remove Duplicates from Sorted Array
Given a sorted array, 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 in place with
2016-12-08 17:56:25
378
转载 深入理解Java:注解(Annotation)自定义注解入门
转自 http://www.cnblogs.com/peida/archive/2013/04/24/3036689.html深入理解Java:注解(Annotation)自定义注解入门 要深入学习注解,我们就必须能定义自己的注解,并使用注解,在定义自己的注解之前,我们就必须要了解Java为我们提供的元注解和相关定义注解的语法。元注解: 元注解的作用就是负责
2016-11-09 22:33:24
281
原创 [leetcode]25. Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is
2016-11-01 18:48:09
313
原创 [leetcode]24. Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y
2016-11-01 18:43:27
337
原创 [leetcode]23. Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Leetcode 21题是合并两个链表。合并K个链表的方法就是2的进一步。有两种方法:1 归并法。即每次链表数组中相邻的两个链表合并,结果为一个新的链表数组,重复之前的流程知道数组中只有一个元
2016-11-01 18:38:53
200
原创 [leetcode]22. Generate Parentheses
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:[ "((()))", "(()())", "(())()", "()(())
2016-11-01 18:30:32
279
原创 [leetcode]21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.直接上代码了。java/** * Definition for singly-linked list
2016-10-19 20:39:45
251
原创 [leetcode]20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all va
2016-10-19 20:22:25
378
原创 [leetcode]19. Remove Nth Node From End of List
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 end, the
2016-10-19 00:03:11
260
原创 [leetcode]18. 4Sum
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
2016-10-18 23:25:16
287
原创 [leetcode]17. Letter Combinations of a Phone Number
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:Di
2016-10-18 23:20:01
267
原创 [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 exact
2016-10-17 22:34:23
256
原创 [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
2016-10-17 22:19:46
250
原创 [leetcode]14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.比较简单,直接上代码。java代码public class Solution { public String longestCommonPrefix(String[] strs) { if(s
2016-10-15 21:49:09
249
原创 [leetcode]13. Roman to Integer
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.这道题和12题正好相反,但是要比12题难一点。最重要的还是要熟悉对应表。1~9: {"I", "II", "III", "IV", "V", "VI", "VI
2016-10-15 18:21:39
251
原创 [leetcode]12. Integer to Roman
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.这道题基本没什么算法上的难点,就是需要知道罗马字母和整数的对应关系就行了。1~9: {"I", "II", "III", "IV", "V", "VI", "V
2016-10-15 18:13:54
279
原创 [leetcode]11. Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin
2016-10-13 23:21:08
261
原创 [leetcode] 9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of convertin
2016-10-13 23:07:45
277
原创 [leetcode]7. Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321click to show spoilers.Have you thought about this?Here are some good questions to ask before c
2016-10-10 22:47:49
268
原创 [leetcode]5. Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.本题是求一个字符串的最长的回文子串。
2016-10-10 22:09:20
226
原创 [leetcode]4. Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).Example 1:nums1 =
2016-10-09 21:31:38
231
原创 [leetcode]3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "
2016-10-09 00:03:03
254
原创 [leetcode] 2. Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link
2016-10-07 21:34:40
266
原创 [leetcode] 1. Two Sum
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 =
2016-10-07 17:30:22
354
原创 MySql 64位 windows下环境配置
现在Mysql官网只有32位的安装包,64位的是zip包,下载下来解压后是直接可以运行的程序。在windows下使用不是那么方便,下面来实践一下Win7下的环境搭建。我用的版本是 mysql-5.7.13-winx64。1 解压缩后文件的情况。2 新建一个my.ini设置一下默认的server的一些选项。里面加入如下内容:[mysql]default-charact
2016-07-16 19:23:02
534
转载 nodejs require 加载机制
require(路径.扩展名):如果 路径.扩展名 存在执行加载 并 返回否则抛出异常require(路径):如果 路径.js 存在执行加载 并 返回如果 路径.node 存在执行加载 并 返回如果 路径/package.json 存在执行加载(package.json 中 main属性对应的路径) 并 返回如果 路径/index.js 存在执行
2016-06-02 14:04:13
1880
原创 Ubuntu忘记root密码恢复方法
1 重启机器,在选择系统的时候选择advanced options2 进去之后会发现有若干个带recovery的选项,选择其中一个,注意不要回车,按“e”键进入编辑模式。3 进去之后是一个文本,找到一行最后的结尾是 recovery nomodeset,把 “recovery nomodeset” 删掉 ,然后在这行加入quiet splash rw init=/bin/bash。4
2016-04-12 16:58:01
877
转载 XSS攻击简介
最近才开始研究HTML以及安全问题。如果有什么说得不对的地方,望请指出。 在网络应用安全中,XSS可能是最常见,范围最大,所包含攻击方法最多,同时也是最难以理解的一种攻击。在OWASP所列出的十大网络应用安全风险中,其排名第二位,仅次于SQL Injection。 而在本篇文章中,我们将一步一步深入挖掘XSS的攻击流程,攻击手段,以及防御方法等各个方面。 XSS示例 在深
2016-01-26 15:09:49
584
原创 Node.js HTTP开发遇到的若干问题
1 Error: getaddrinfo ENOTFOUND http://xx.dd.com 解决方法:在node.js中使用http或者https发送请求的时候host不要带http://或者https://,直接写xx.yy.com即可。2 Error: write EPROTO 101057795:error:140770FC:SSL routines:SSL23_GET_SE
2015-12-16 15:33:20
9960
转载 一次非常有意思的SQL优化经历
原文:http://www.cnblogs.com/tangyanbo/p/4462734.html补充:看到这么多朋友对sql优化感兴趣,我又重新补充了下文章的内容,将更多关于sql优化的知识分享出来,喜欢这篇文章的朋友给个赞吧,哈哈,欢迎交流,共同进步。2015-4-30补充:非常感觉编辑的推荐,同时又对慢查询语句优化了一遍,并附上优化记录,欢迎阅读文章。场景
2015-05-15 09:27:11
452
转载 可扩展Web架构与分布式系统
开放源代码已经成为一些大型网站的基本原则。而在这些网站成长的过程中,一些优秀的实践经验和规则也出现在他们的结构中。本文旨在介绍一些在大型网站结构设计的过程中需要注意的关键问题以及实现目标的基础工作。本文侧重于介绍网络系统,尽管一些准则在其他分布式系统中也是适用的。1.1. web分布式系统的设计原则搭建和运营一个可伸缩的web站点或者应用程序意味着什么?在原始层面上这仅仅是用户通过互联
2015-05-11 22:43:39
876
转载 从Java视角理解CPU缓存(CPU Cache)
众所周知, CPU是计算机的大脑, 它负责执行程序的指令; 内存负责存数据, 包括程序自身数据. 同样大家都知道, 内存比CPU慢很多. 其实在30年前, CPU的频率和内存总线的频率在同一个级别, 访问内存只比访问CPU寄存器慢一点儿. 由于内存的发展都到技术及成本的限制, 现在获取内存中的一条数据大概需要200多个CPU周期(CPU cycles), 而CPU寄存器一般情况下1个CPU周期
2015-04-08 22:12:00
697
转载 ubuntu图下安装软件出现You might want to run 'apt-get -f install' to correct these解决
今天在ubuntu下安装任何软件都提示以下错误:You might want to run 'apt-get -f install' to correct these:The following packages have unmet dependencies: kate : Depends: kdelibs4c2a (>= 4:3.5.9) but it is not going t
2015-03-24 22:40:07
2450
转载 linux执行scp命令出错
执行scp或ssh-copy-id -i 出现下面的错误[plain] view plaincopy[jifeng@jifeng01 ~]$ ssh-copy-id -i ~/.ssh/id_rsa.pub jifeng@jifeng03 28 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2015-03-24 10:24:27
4394
原创 ubuntu下安装软件Could not get lock /var/lib/dpkg/lock错误
今天在ubuntu安装ssh的时候报了下面的错误:E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)E: Unable to lock the administration directory (/var/lib/dpkg/), is another process
2015-03-09 17:05:27
1309
原创 linux下git命令行的颜色配置
在Windows系统中安装了git客户端之后在git bash中用git命令 git status,git diff等时,修改过的文件自动显示为红色。在linux中git安装后颜色是不自动设置的。下面的命令设置git的颜色:git config --global color.status auto git config --global color.diff auto git conf
2015-03-04 13:40:43
4106
原创 git学习(2)
1 创建分支 git branch dev git checkout dev 也可以一步完成 git checkout -b dev2 查看当前分支 git branch3 合并分支 git merge dev3 删除一个分支 git branch -d dev5 查看分支合并的情况git log --graph --pre
2015-02-27 16:49:07
616
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人