自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(60)
  • 资源 (1)
  • 收藏
  • 关注

原创 Palindrome Pairs

题目描述:Given a list of unique words. Find all pairs of distinct indices(i, j) in the given list, so that the concatenation of the two words, i.e.words[i] + words[j] is a palindrome.Example 1:

2016-05-31 18:14:54 287

原创 H-Index

题目描述:Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikip

2016-05-30 20:07:53 537

原创 Isomorphic Strings

题目描述:Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to gett.All occurrences of a character must be replaced wit

2016-05-29 17:14:02 334

原创 Count Primes

题目描述:Description:Count the number of prime numbers less than a non-negative number, n.找到比n小的所有质数的个数这里用wiki上的图来说,就很显然了。比如n=52,那么就先让2的倍数全纪录下来,然后3的倍数,直到7的倍数,然后其他没有记录下来的就是质数了,加起来就行。

2016-05-29 16:48:53 271

原创 Happy Number

题目描述:Write an algorithm to determine if a number is "happy".A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the

2016-05-29 16:11:16 311

原创 Repeated DNA Sequences

题目描述:All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within the DNA.

2016-05-29 15:15:05 351

原创 Fraction to Recurring Decimal

题目描述:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose the repeating part in parenthe

2016-05-29 11:55:06 297

原创 Max Points on a Line

题目描述:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.给n个点,看最多多少个点在同一条线。我真的服了自己,一开始想那么麻烦,还去求y=kx+b。最后还有问题,因为当k失去精度后,b的计算可能不相等。下面是一段非常复杂的计算,还没有

2016-05-28 21:01:48 294

原创 Copy List with Random Pointer

题目描述:A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.深度复制,就所有的节点另外开辟空间咯。如果是一

2016-05-28 16:05:08 330

原创 Maximal Rectangle

这个题和Largest rectangle in histogram有异曲同工之妙, 把每一行上面的矩形看成是histogram就行了代码如下:public class Solution { public int maximalRectangle(char[][] matrix) { if(matrix==null||matrix.length==0) return 0;

2016-05-28 09:09:24 249

原创 Struts基础知识

上图是model2的流程。在model2架构中,Servlet作为前端控制器,负责接收客户端发送的请求,在Servlet中只包含控制逻辑和简单地前端处理;然后调用后端JavaBean来完成实际的逻辑处理,最后转发到相应的JSP页面处理现实逻辑。Struts2应用开发步骤: 1、在web.xml文件中定义核心filter来拦截用户请求。 2、如果用post提交请求,则定义包含表单数据的jsp页面。

2016-05-27 12:04:20 420

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

2016-05-26 17:26:48 270

原创 Minimum Window Substring

题目描述:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T = "ABC"Minimum window is

2016-05-26 11:54:29 265

原创 关于java中一些代码的理解

Iterable和Iterator的区别 首先Iterable是java.lang包中的,它的三个接口方法是 forEach(Consumer< ? super T> action) 、iterator() 、spliterator() 很多类都继承了Iterable,这样就可以调用他们的方法。Iterator是java.util包中的,它的四个接口方法是 forEachRemaining

2016-05-25 21:49:14 609

原创 Group Anagrams

题目描述:Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]Note:

2016-05-25 20:46:15 367

原创 Substring with Concatenation of All Words

题目描述: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) ins that is a concatenation of each word in words exactly o

2016-05-25 19:02:38 238

原创 Sudoku Solver

题目描述:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.A sudok

2016-05-25 16:54:44 250

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

2016-05-24 22:36:08 211

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

2016-05-24 21:37:08 202

原创 Odd Even Linked List

题目描述:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.You should try to d

2016-05-24 11:42:09 249

原创 Palindrome Linked List

题目描述:Given a singly linked list, determine if it is a palindrome.Follow up:Could you do it in O(n) time and O(1) space?这个题要求空间复杂度为O(1),不能一开始就逆序,然后逐个比较,这样不符合要求。链表无非就是逆序,插入,这个题和Reorder l

2016-05-24 11:12:16 186

原创 Reverse Linked List

题目描述:Reverse a singly linked list.很简单,必须一次ac。public ListNode reverseList(ListNode head) { if(head==null){ return null; } ListNode last=head; while(last.next!=null){ last=

2016-05-24 10:42:56 205

原创 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题目简单,一次ac,代码如下:

2016-05-24 10:33:27 246

原创 Intersection of Two Linked Lists

题目描述:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists: A: a1 → a2 ↘

2016-05-24 10:17:11 267

原创 Insertion Sort List

题目描述:Sort a linked list using insertion sort.插入排序,题目很简单,只是换成链表实现而已。代码如下所示public ListNode insertionSortList(ListNode head) { ListNode cur=head; int sum=0; while(cur!=null){ cur=cur.n

2016-05-24 09:48:30 210

原创 Sort List

题目描述: Sort a linked list in O(n log n) time using constant space complexity.很自然二分法,代码如下:public ListNode sortList(ListNode head) { //下面head.next==null不能丢!! if(head==null||head.next==null)

2016-05-23 22:18:21 232

原创 Reorder List

题目描述: Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes’ values.For example, Given {1,2,3,4}, reorder it to {1

2016-05-23 20:38:40 234

原创 Reverse Linked List II

题目: Reverse a linked list from position m to n. Do it in-place and in one-pass.For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note: Given m, n satisfy the followi

2016-05-23 15:09:58 235

原创 Remove Duplicates from Sorted List II

题目描述: 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->

2016-05-23 13:41:04 299

原创 Rotate List

题目描述: Given a list, rotate the list to the right by k places, where k is non-negative.For example: Given 1->2->3->4->5->NULL and k = 2, return 4->5->1->2->3->NULL.这个题本身没难度,就是有一点,要注意这里要k可以大于n,这个时候取余就

2016-05-23 13:32:37 240

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

2016-05-22 17:37:53 210

原创 远程主机强迫关闭了一个现有的连接

严重: Failed to initialize end point associated with ProtocolHandler ["http-nio-8080"]java.io.IOException: Unable to establish loopback connection at sun.nio.ch.PipeImpl$Initializer.run(PipeImpl.jav

2016-05-19 10:53:29 13284

原创 杂七杂八

myeclipse中导入jar包的时候也要在tomcat中导入该jar包。 否则会出现下面的问题: A child container failed during start java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [St

2016-05-18 18:53:12 346

原创 jsp/servlet基础知识

不使用IDE构建web项目: |–WebRoot | |-WEB-INF | | |-classes | | |-lib | | |-web.xml | |-styles | |-jsp | |-imag

2016-05-18 14:55:37 539

原创 Minimum Size Subarray Sum

题目描述: Given an array of n positive integers and a positive integer s, find the minimal length of a subarray of which the sum ≥ s. If there isn’t one, return 0 instead.For example, given the array [2,3

2016-05-15 20:26:54 281

原创 Combination Sum III

题目描述: Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Ensure that numbers

2016-05-14 20:43:02 227

原创 Contains Duplicate II

题目描述: Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.这里用H

2016-05-14 16:02:43 216

原创 Summary Ranges

题目描述: Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return [“0->2”,”4->5”,”7”].这个题很简单,i指向range的开始,j指向range的末尾,记得加入String后i的指针要移动就行

2016-05-14 15:46:09 332

原创 Majority Element II

题目描述: Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. The algorithm should run in linear time and in O(1) space.暴力法超时,哈希表法空间复杂度超过。摩尔投票法 假设an={2,2,3,3,1,4,0}

2016-05-14 15:17:41 240

原创 Product of Array Except Self

题目描述: Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].Solve it without division and in O(n

2016-05-14 10:58:48 187

反编译插件jad

我用的是myeclipse2015,成功了,很方便也很必要的插件。

2016-04-22

空空如也

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

TA关注的人

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