- 博客(49)
- 资源 (1)
- 收藏
- 关注
转载 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件
原文地址:http://www.cnblogs.com/lichenwei/p/4145696.htmlMybatis属于半自动ORM,在使用这个框架中,工作量最大的就是书写Mapping的映射文件,由于手动书写很容易出错,我们可以利用Mybatis-Generator来帮我们自动生成文件。 1、相关文件关于Mybatis-Generator的下载可以到这个地址:https://github.co...
2018-04-09 00:26:17
216
转载 lombok
官方文档:https://www.projectlombok.org/转载:http://www.cnblogs.com/holten/p/5729226.htmllombok简介lombok是暑假来到公司实习的时候发现的一个非常好用的小工具,刚见到的时候就感觉非常惊艳,有一种相见恨晚的感觉,用了一段时间之后感觉的确挺不错,所以特此来推荐一下。lombok的官方地址:https://project...
2018-04-08 15:54:23
224
原创 网页正文提取+HMM命名实体识别+CRF命名实体识别
推荐一篇博客:http://blog.youkuaiyun.com/AJAXHu/article/details/48382381 开源的WebCollector爬虫确实很好用,并且提供了网页正文提取的模块。 提供了图形界面的简单配置,Log也比较全面,WebCollector-Hadoop是WebCollector的分布式版本。 对比自己一直使用的Scrapy-redis,感觉WebCollector更
2017-10-28 21:09:40
3262
2
原创 《剑指offer》牛客网java题解-合并两个排序的链表
输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则。两个排序链表的合并就是不停的去比较两个链表头的值,然后指针后移。 leetcode上有拓展是k个链表的问题,之后整理leetcode题解时再写。public class Solution { public ListNode Merge(ListNode l1,ListNode l2) {
2017-08-13 18:31:26
389
原创 《剑指offer》牛客网java题解-反转链表
输入一个链表,反转链表后,输出链表的所有元素。链表反转的问题,就是在链表头加一个哨兵,然后不停的把后面的节点采用头插法加入。这种代码最起码也要背下来。public class Solution { public ListNode ReverseList(ListNode head) { if (head == null) return null; if (head.
2017-08-13 18:28:17
588
原创 《剑指offer》牛客网java题解-链表中倒数第k个结点
输入一个链表,输出该链表中倒数第k个结点。 采用双指针,让一个先走k步,第二个再开始走,当第一个走到结尾后,第二个指针就走到了倒数的第k个节点。public class Solution { public ListNode FindKthToTail(ListNode head,int k) { int i =1; if(head == null) retu
2017-08-13 18:26:11
347
原创 《剑指offer》牛客网java题解-调整数组顺序使奇数位于偶数前面
输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于位于数组的后半部分,并保证奇数和奇数,偶数和偶数之间的相对位置不变。题目中要求了相对位置不变,如果没有这个要求的话,可以才有双指针,从头和尾分别扫描然后交换。第一种解法是开辟了新的数组,等于用空间换时间。import java.util.ArrayList;import java.util.Li
2017-08-13 18:23:39
352
原创 《剑指offer》牛客网java题解-数值的整数次方
给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。 double类型不能直接用==判断,底数等于0指数小于0时不能将0作为分母。 使用了优化的求幂函数public class Solution { public double Power(double base, int exponent) { if (equal
2017-08-13 18:03:26
645
原创 《剑指offer》牛客网java题解-二进制中1的个数
输入一个整数,输出该数二进制表示中1的个数。其中负数用补码表示。 public int NumberOf1(int n) { int count = 0; while(n!= 0){ count++; n = n & (n - 1);//消除最低位的1 }
2017-08-13 17:57:21
438
2
原创 《剑指offer》牛客网java题解-矩形覆盖
我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?开始读错题目要求,以为是要覆盖n*n的大矩形。。。 其实这道题和前面的跳台阶问题一模一样,对于行来说,每次可以增加一行或者两行。 感觉牛客网上的连续这几道题出的太重复了。public class Solution { public int RectCover(i
2017-08-13 17:52:10
270
原创 《剑指offer》牛客网java题解-变态跳台阶
一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法。 我的理解为,每一个台阶可以由前一个台阶跳过来和之前到前一个台阶的方法的最后一跳加1到达。public class Solution { public int JumpFloorII(int n) { if(n <= 2) return n; int
2017-08-13 17:43:10
438
原创 《剑指offer》牛客网java题解-跳台阶
一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法。和上一题一样。public class Solution { public int JumpFloor(int n) { if (n<=2) return n; int a =1; int b =2; int c = 0;
2017-08-13 17:32:21
315
原创 《剑指offer》牛客网java题解-斐波那契数列
大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项。 n<=39 递归的解法: 很明显递归的话进行了大量的重复计算,这是需要避免的事情,所以递归的效率很差。 public class Solution { public int Fibonacci(int n) { if(n==0) return 0; if (n==1||n=
2017-08-13 17:29:13
353
原创 《剑指offer》牛客网java题解-旋转数组的最小数字
把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个非递减排序的数组的一个旋转,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。首先最容易想到的就是遍历一遍数组,找出下一个小于上一个的数字import java.util.ArrayList;publ
2017-08-12 21:09:52
488
原创 《剑指offer》牛客网java题解-用两个栈实现队列
用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。这是一道比较经典的题,解法有多种,同样的还有用两个队列实现栈,leetcode上的原题。此解法是push的时候把stack1弹向stack2,然后再从stack2弹回来。mport java.util.Stack;public class Solution { Stack<Integer> stack1 =
2017-08-12 20:58:28
311
原创 《剑指offer》牛客网java题解-重建二叉树
输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并返回。从前序遍历序列中找根,然后去中序遍历序列中找根左面的为左子树,右面的为右子树,递归即可完成重建二叉树。public class Solution { publ
2017-08-12 20:53:21
544
原创 《剑指offer》牛客网java题解-从尾到头打印链表
输入一个链表,从尾到头打印链表每个节点的值。 利用栈,压入和弹出即可import java.util.Stack;import java.util.ArrayList;public class Solution {public ArrayList<Integer> printListFromTailToHead(ListNode listNode) { Stack<Integ
2017-08-12 20:50:06
392
原创 《剑指offer》牛客网java题解-替换空格
请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。用java自带的函数replaceAll就可以解决,这样有点太取巧。public class Solution { public String replaceSpace(StringBuffer str) { return
2017-08-12 20:46:32
478
原创 《剑指offer》牛客网java题解
上个月刷了一遍剑指offer的题目,都是一些很基础难度并不大的题,最近整理了一下题解 66题解链接: 按人气排序 二维数组的查找 替换空格 从尾到头打印链表 重建二叉树 用两个栈实现队列 旋转数组的最小数字 斐波那契数列 跳台阶 变态跳台阶 矩形覆盖 二进制中1的个数 数值的整数次方 调整数组顺序使奇数位于偶数前面 链表中倒数第k个结点 反转链表 合并两个排序的链
2017-08-12 20:40:56
588
原创 《剑指offer》牛客网java题解-二维数组中的查找
题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。从右上角开始找,如果目标值小于当前则左移动,大于则下移public class Solution { public boolean Find(int target, int [][] array) { in
2017-08-12 20:36:19
328
原创 Leetcode655. Print Binary Tree
Print a binary tree in an m*n 2D string array following these rules:The row number m should be equal to the height of the given binary tree. The column number n should always be an odd number. The ro
2017-08-10 00:00:51
673
原创 Leetcode654. Maximum Binary Tree
Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:The root is the maximum number in the array. The left subtree is the maximum tree constructed from
2017-08-09 23:57:41
1089
原创 Leetcode653. Two Sum IV - Input is a BST
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.Example 1: Input: 5 / \ 3 6 / \ \
2017-08-09 23:54:47
283
原创 Leetcode99. Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note: A solution using O(n) space is pretty straight forward. Could you devise a const
2017-07-29 08:29:37
243
原创 Leetcode98. Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than the node’s key. The right
2017-07-28 22:03:00
176
原创 Leetcode211. Add and Search Word - Data structure design
Design a data structure that supports the following two operations:void addWord(word) bool search(word) search(word) can search a literal word or a regular expression string containing only letters a
2017-07-28 21:21:13
290
原创 Leetcode197. Rising Temperature
Given a Weather table, write a SQL query to find all dates’ Ids with higher temperature compared to its previous (yesterday’s) dates.+———+————+——————+ | Id(INT) | Date(DATE) | Temperature(INT) | +———
2017-07-14 00:20:56
339
原创 Leetcode596. Classes More Than 5 Students
There is a table courses with columns: student and classPlease list out all classes which have more than or equal to 5 students.For example, the table:+———+————+ | student | class | +———+————+
2017-07-14 00:19:17
1408
原创 Leetcode183. Customers Who Never Order
Suppose that a website contains two tables, the Customers table and the Orders table. Write a SQL query to find all customers who never order anything.Table: Customers.+—-+——-+ | Id | Name | +—-+——-
2017-07-03 00:10:59
260
原创 Leetcode182. Duplicate Emails
Write a SQL query to find all duplicate emails in a table named Person.+—-+———+ | Id | Email | +—-+———+ | 1 | a@b.com | | 2 | c@d.com | | 3 | a@b.com | +—-+———+ For example, your query shou
2017-07-02 23:45:20
184
原创 Leetcode177. Nth Highest Salary
Write a SQL query to get the nth highest salary from the Employee table.+—-+——–+ | Id | Salary | +—-+——–+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +—-+——–+ For example, given the above Em
2017-06-30 01:08:54
250
原创 Leetcode176. Second Highest Salary
Write a SQL query to get the second highest salary from the Employee table.+—-+——–+ | Id | Salary | +—-+——–+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +—-+——–+ For example, given the above
2017-06-30 00:55:21
193
原创 Leetcode413. Arithmetic Slices
A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequence:1,
2017-06-30 00:35:30
161
原创 Leetcode442. Find All Duplicates in an Array
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without extra space
2017-06-30 00:14:02
231
原创 Leetcode485. Max Consecutive Ones
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 consecutive 1s.
2017-06-29 23:32:54
158
原创 mysql group by 之前进行排序
mysql 从表中找出某一列不重复的数据,并且按照时间找出最早的一条记录。select * from(select * from order by 时间 asc) agroup by a.某列目前只想到这种写法
2017-06-29 23:26:06
4914
3
原创 Leetcode553. Optimal Division
Given a list of positive integers, the adjacent integers will perform the float division. For example, [2,3,4] -> 2 / 3 / 4.However, you can add any number of parenthesis at any position to change the
2017-06-27 23:23:48
199
原创 Leetcode513. Find Bottom Left Tree Value
Given a binary tree, find the leftmost value in the last row of the tree.Example 1: Input:2/ \ 1 3Output: 1 Example 2: Input: 1 / \ 2 3 / / \4 5 6 / 7Output: 7 Note
2017-06-27 22:55:16
174
原创 Leetcode463. Island Perimeter
ou 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 completely su
2017-06-26 23:51:48
179
原创 Leetcode412. Fizz Buzz
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”. For n
2017-06-23 00:38:43
222
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人