自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

梦想还是要有的,万一实现了呢?

  • 博客(55)
  • 收藏
  • 关注

转载 freemaker学习

FreeMarker是一个用Java语言编写的模板引擎,它基于模板来生成文本输出。FreeMarker与Web容器无关,即在Web运行时,它并不知道Servlet或HTTP。它不仅可以用作表现层的实现技术,而且还可以用于生成XML,JSP或Java 等。FreeMarker模板文件主要由如下4个部分组成: 1,文本:直接输出的部分 2,注释:格式部分,不会输出 3,插值:即

2015-06-17 19:49:54 387

转载 RPC学习

RPC (Remote Procedure Call)是一种进程间通信方式。它允许程序调用另一个地址空间(通常是共享网络的另一台机器上)的过程或函数,而不用程序员显式编码这个远程调用的细节。即程序员无论是调用本地的还是远程的,本质上编写的调用代码基本相同。RPC 结构1. User2. User-stub3. RPCRuntime4. Server-stub5. S

2015-06-11 09:50:19 496

原创 IDEA学习

一、添加插件ctrl+alt+s  settings ->plugins->输入需要添加的插件名称->OK1.热部署插件有关热部署:所谓热部署,就是指应用在运行的时候进行软件升级,却不需要重新启动应用。对于Java应用程序来说,热部署就是在运行时更新Java类文件。二、

2015-06-10 17:48:08 379

转载 JUnit学习

JUnit是由 Erich Gamma 和 Kent Beck 编写的一个回归测试框架(regression testing framework)。Junit测试是程序员测试,即所谓白盒测试,因为程序员知道被测试的软件如何(How)完成功能和完成什么样(What)的功能。Junit是一套框架,继承TestCase类,就可以用Junit进行自动测试了。

2015-06-10 15:11:25 427

原创 junit,rpc,ci,linux,pegion,freemaker,spring,structs,ibatis

q

2015-06-10 11:29:28 560

原创 JSON学习

JSON:JavaScript 对象表示法(JavaScript Object Notation)。JSON 是存储和交换文本信息的语法。类似 XML。JSON 比 XML 更小、更快,更易解析。JSON 使用 JavaScript 语法来描述数据对象,但是 JSON 仍然独立于语言和平台,JSON 解析器和 JSON 库支持许多不同的编程语言。与XML的相似之处

2015-06-10 09:38:22 307

原创 xml学习

xml的作用是将易变的数据单独取出来,如果发生改变,不用改变全部的数据,而只需要改变xml

2015-06-03 18:01:21 254

转载 maven学习

Java项目中,每个项目都有很多依赖的Jar包,我们一般都放在自己项目的lib目录中,这样就会导致同样的Jar包在各个不同的项目中重复出现,时间长了将会浪费很大的硬盘空间。使用Maven对项目进行管理就可以解决以上问题。1.配置maven环境2.修改仓库位置3.创建maven项目通过maven命令行创建一个自己的项目:mvn archetype:create -Dgroup

2015-06-02 17:02:31 274

原创 海量数据中找第k大个数

普通数组中查找第k大个数:(1)首先会想到将数组按降序排列,输出第k个数即可,时间复杂度为O(nlogn)(快排,堆排);(2)还会想到只对前k个数进行排序,时间复杂度为O(n*k)(冒泡,选择);但是这些方法在面临海量数据的时候就不太够用了,因为数据量大,所以我们考虑在上述方法的基础上进行优化,比如减少遍历次数等//海量数据中查找第k大的数public class Try {

2015-05-10 18:43:43 935

原创 Add Binary

Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".public class Solution { public String addBinary(String a, String b) {

2015-05-04 22:18:36 369

原创 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

2015-04-30 20:45:19 376

原创 判断数组中是否有重复数字(two ways +位运算)

//判断数组中是否有重复的数字,有则返回true,没有则返回false//方法一:先用时间复杂度为O(nlogn)的排序将数组重建,然后遍历寻找 //方法二:新建一个数组型hash表,key存num[i], value存num[i]出现的次数。时间复杂度为O(n),空间复杂度为O(n) public static boolean Dup(int[] num){ int hash[]

2015-04-28 21:47:58 1668

原创 返回字符串中第一个只出现过一次的字符(hash)

public class Try { public static void main(String[] args){ String s = "aabcceeff"; System.out.println(firstOnce(s)); } public static int firstOnce(String s){ int hash[] = new int[256]; in

2015-04-28 20:52:00 338

原创 Sort Colors (two ways)

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers 0,

2015-04-28 18:21:06 233

原创 Search Insert Position(two ways)

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.He

2015-04-28 15:58:00 250

原创 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. You

2015-04-28 13:00:03 337

原创 Linked List Cycle I / II

Given a linked list, determine if it has a cycle in it. Can you solve it without using extra space?/** Definition for singly-linked list.*/class ListNode { int val; ListNode next;

2015-04-28 08:37:25 252

原创 Insertion Sort List

Sort a linked list using insertion sort.public class Whynot { public ListNode insertionSortList(ListNode head) { if (head == null){ return null; } ListNode dummy = new ListNode(-1); dum

2015-04-27 21:56:52 253

原创 Remove Duplicates from Sorted List II (read and think again!)

Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example,Given 1->2->3->3->4->4->5, return 1->2->5.Given 1->1-

2015-04-27 20:31:48 401

原创 Remove Duplicates from Sorted List

Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3./** * Definition for s

2015-04-27 17:31:58 169

原创 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 linked li

2015-04-27 16:47:32 219

原创 Intersection of Two Linked Lists(有优化)

Write a program to find the node at which the intersection of two singly linked lists begins.A:                a1 → a2                              ↘                                 c1 → c2 → c3

2015-04-27 15:25:17 240

原创 Remove Linked List Elements

Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 --> 3 --> 4 --> 5/** * Definition for si

2015-04-27 12:59:09 220

原创 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./** * Definition for singly-linked list. * public class

2015-04-27 11:44:51 224

原创 Best Time to Buy and Sell Stock II

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on

2015-04-26 09:55:07 306

原创 Best Time to Buy and Sell Stock III

Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You may not

2015-04-25 15:59:15 310

原创 Merge Sorted Array

Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from

2015-04-23 16:25:04 331

原创 Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.找出所有字符串最长公共前缀public class Solution { //runtime = 291ms public String longestCommonPrefix(String[] strs) {

2015-04-23 09:33:53 269

原创 Min Stack

Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top() -- Get

2015-04-23 08:15:16 232

原创 Happy Number

简单点说,就是将一个整数每一位上的数拆开,19—1,9,再分别对拆开的数求平方,求和得到新的数,直到得到1则返回true,若得到的新数在前面出现过,则返回false。自己写了个runtime = 261ms的算法,后来又看到一个更高明的解法,一起记录下来。public class Solution { //runtime = 261ms public boolean isHa

2015-04-22 22:16:31 266

原创 Compare Version Numbers

Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the version strings are non-empty and co

2015-04-22 16:40:02 266

原创 Excel Sheet Column Title

public class Solution { //runtime = 171ms public String convertToTitle(int n) { StringBuilder s =new StringBuilder(); char ch[] = new char[50]; if (n <= 0){ return "

2015-04-17 10:01:08 252

原创 Valid Sudoku

论看懂题目的重要性!!!这道题目实际是要求判断给出的数独是否是有效数独(每行每列及每个小九宫格都没有重复数字),而不是填充数独!没有看清题目的人绞尽脑汁地在纸上把数独填满了,又绞尽脑汁地想着怎样用代码实现,结果知道真相后,只能绞尽脑汁地骂自己。。。//分别对行,列,以及九宫格进行判断,确认是否每行、每列以及

2015-04-16 20:23:32 235

原创 Roman to Integer

Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.tips:1~9: {"I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};10~90: {"X",

2015-04-16 15:46:31 275

原创 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

2015-04-16 11:52:20 227

原创 ZigZag Conversion

//时间复杂度为O(n),运行时间为375mspublic class Solution { public String convert(String s, int nRows) { char str[] = s.toCharArray(); int len = str.length; if ((len == 0) || (nRows == 1)

2015-04-15 19:40:33 333

原创 Implement strStr()(3 ways)

Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.public class Solution { public int strStr(String haystack, String needle) { char

2015-04-14 22:10:05 241

原创 Rotate Array(3 ways)

Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Could you do it in-place with O(1) extra space?

2015-04-12 13:40:14 258

原创 Excel Sheet Column Number

Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ..

2015-04-09 21:09:36 259

原创 Best Time to Buy and Sell Stock

Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),

2015-04-09 14:00:02 269

空空如也

空空如也

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

TA关注的人

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