【Java】
goto456
这个作者很懒,什么都没留下…
展开
-
【Java】Java中文分词器Ansj的使用
以前都是用C++对中文进行分词,也用过Python的“结巴”分词,最近用了一下Java的Ansj中文分词,感觉还不错。下面是用Ansj对中文进行分词的一个简单例子,希望能对大家有用。1.下载Ansj的相关jar包要用Ansj进行中文分词,必须先下载Ansj的jar包,下载地址可以参考:https://github.com/NLPchina/ansj_seg2.程序代原创 2014-11-26 12:57:27 · 28282 阅读 · 6 评论 -
【LeetCode】18. 4Sum - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given an array nums of n integers and an integer target, are there elements a, b, c, and d in nums such that a + b + c + d = target? Find all unique quadruplets...原创 2018-11-20 08:07:05 · 537 阅读 · 0 评论 -
【LeetCode】12. Integer to Roman - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D...原创 2018-11-18 11:07:16 · 287 阅读 · 0 评论 -
【LeetCode】13. Roman to Integer - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 100D...原创 2018-11-18 11:27:02 · 837 阅读 · 0 评论 -
【LeetCode】14. Longest Common Prefix - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".Example 1:Inpu...原创 2018-11-18 11:40:39 · 442 阅读 · 0 评论 -
【LeetCode】26. Remove Duplicates from Sorted Array - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: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 ano...原创 2018-11-24 12:34:27 · 538 阅读 · 0 评论 -
【LeetCode】22. Generate Parentheses - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: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-11-23 08:24:25 · 427 阅读 · 0 评论 -
【LeetCode】16. 3Sum Closest - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integer...原创 2018-11-18 15:14:32 · 406 阅读 · 0 评论 -
【LeetCode】15. 3Sum - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero...原创 2018-11-18 12:51:19 · 402 阅读 · 0 评论 -
【LeetCode】27. Remove Element - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: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 m...原创 2018-11-24 15:02:08 · 299 阅读 · 0 评论 -
【LeetCode】29. Divide Two Integers - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given two integers dividend and divisor, divide two integers without using multiplication, division and mod operator.Return the quotient after dividing dividen...原创 2018-11-28 22:58:40 · 1104 阅读 · 0 评论 -
【LeetCode】28. Implement strStr() - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: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 = “hell...原创 2018-11-26 23:15:45 · 505 阅读 · 0 评论 -
【LeetCode】30. Substring with Concatenation of All Words - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation o...原创 2018-12-03 22:21:04 · 621 阅读 · 0 评论 -
【LeetCode】31. Next Permutation - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it mus...原创 2018-12-04 08:22:04 · 516 阅读 · 0 评论 -
【LeetCode】32. Longest Valid Parentheses - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: “(()”Ou...原创 2018-12-09 14:38:00 · 636 阅读 · 0 评论 -
【LeetCode】33. Search in Rotated Sorted Array - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: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 giv...原创 2018-12-09 21:54:55 · 358 阅读 · 0 评论 -
【LeetCode】34. Find First and Last Position of Element in Sorted Array - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: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 mu...原创 2018-12-16 11:52:33 · 975 阅读 · 0 评论 -
【LeetCode】35. Search Insert Position - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: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 m...原创 2018-12-16 12:11:13 · 740 阅读 · 0 评论 -
【LeetCode】17. Letter Combinations of a Phone Number - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (jus...原创 2018-11-20 07:24:35 · 394 阅读 · 0 评论 -
【LeetCode】25. Reverse Nodes in k-Group - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the lengt...原创 2018-11-24 10:23:36 · 726 阅读 · 0 评论 -
【LeetCode】24. Swap Nodes in Pairs - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: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....原创 2018-11-24 10:15:45 · 633 阅读 · 0 评论 -
【Java】MyEclipse中复制项目或修改项目名字出现问题
今天用MyEclipse复制一个已经存在的项目,并将名字修改成另外一个项目时,出现了一个问题困扰我多时,后来终于解决了。1.问题描述复制并修改名字后,部署到Tomcat上跑,结果发现运行时都是复制前的那个项目的名字,修改后的项目的名字完全没有起到作用。2.解决办法点击新的项目名,右键->Properties->MyEclipse->Web,将Web Context-原创 2014-12-01 19:27:56 · 6772 阅读 · 0 评论 -
【Java】Java程序打包成jar包在Linux上运行
当需要把在Windows上开发的Java程序用在Linux上运行时,就需要吧该Java程序打包成jar包上传到Linux上去运行。1.Java程序打包成可运行的jar包2.打包后的jar包在Linux上运行原创 2015-01-06 21:29:39 · 71377 阅读 · 3 评论 -
【LeetCode】3. Longest Substring Without Repeating Characters - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc...原创 2018-07-24 22:25:13 · 668 阅读 · 0 评论 -
【LeetCode】1. Two Sum - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: 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 wo...原创 2018-07-13 18:21:33 · 259 阅读 · 0 评论 -
【LeetCode】2. Add Two Numbers - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: 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 s...原创 2018-07-13 18:23:28 · 545 阅读 · 0 评论 -
【LeetCode】5. Longest Palindromic Substring - Java实现
1. 题目描述:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example: Input: “babad” Output: “bab” Note: “aba” is also a va...原创 2018-07-28 19:09:36 · 736 阅读 · 0 评论 -
【LeetCode】4. Median of Two Sorted Arrays - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: 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 co...原创 2018-07-28 19:04:05 · 726 阅读 · 0 评论 -
【LeetCode】6. ZigZag Conversion - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed fo...原创 2018-07-28 21:38:10 · 452 阅读 · 0 评论 -
【LeetCode】7. Reverse Integer - Java实现
1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a 32-bit signed integer, reverse digits of an integer.Example 1: Input: 123 Output: 321Example 2: Input: -123 Output: -321...原创 2018-07-29 13:57:06 · 432 阅读 · 0 评论 -
【LeetCode】9. Palindrome Number - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExampl...原创 2018-11-12 23:23:17 · 473 阅读 · 0 评论 -
【LeetCode】8. String to Integer (atoi) - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace char...原创 2018-11-11 18:08:50 · 508 阅读 · 0 评论 -
【LeetCode】10. Regular Expression Matching - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'.‘.’ Matches any single character.‘*’ Matches ...原创 2018-11-14 08:30:31 · 325 阅读 · 0 评论 -
【LeetCode】19. Remove Nth Node From End of List - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a linked list, remove the n-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After rem...原创 2018-11-21 08:22:05 · 419 阅读 · 0 评论 -
【LeetCode】11. Container With Most Water - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given n non-negative integers a[1], a[2], …, a[n] , where each represents a point at coordinate (i, a[i]). n vertical lines are drawn such that the two endpoint...原创 2018-11-15 08:23:41 · 227 阅读 · 0 评论 -
【LeetCode】20. Valid Parentheses - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open bracke...原创 2018-11-22 07:44:02 · 811 阅读 · 0 评论 -
【LeetCode】21. Merge Two Sorted Lists - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述: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.Example:Input: 1...原创 2018-11-22 07:50:08 · 485 阅读 · 0 评论 -
【LeetCode】23. Merge k Sorted Lists - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]...原创 2018-11-23 22:20:55 · 516 阅读 · 0 评论 -
【LeetCode】36. Valid Sudoku - Java实现
文章目录1. 题目描述:2. 思路分析:3. Java代码:1. 题目描述:Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules:Each row must contain the digits 1-9 wit...原创 2018-12-17 22:05:48 · 544 阅读 · 0 评论