自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(79)
  • 收藏
  • 关注

转载 集合之LinkedList

转至:https://www.cnblogs.com/ITtangtang/p/3948610.html一、源码解析    1、 LinkedList类定义。 public class LinkedList<E> extends AbstractSequentialList<E> implements List<E>, Deque<E&...

2018-06-26 10:13:33 197

原创 集合之ArrayList

package java.util;public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable{ private static final long seria...

2018-06-25 20:14:06 222

原创 [leetcode] 48.Rotate Image

题目:You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?题解:在计算机图像处理里,旋转图片是很常见的,由于图片的本质是二维数

2017-08-17 20:36:18 301

原创 [leetcode] 47. Permutations II

题目:Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[ [1,1,2], [1,2,1

2017-08-17 20:17:27 219

原创 [leetcode] 46. Permutations

题目:Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2],

2017-08-17 19:43:15 201

原创 [leetcode] 33.Search in Rotated Sorted Array

题目: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 given a target value to search

2017-08-16 21:30:25 212

原创 [leetcode] 31. Next Permutation

题目:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest

2017-08-15 19:41:34 200

原创 [leetcode] 29. Divide Two Integers

题目:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.题解:这道题让我们求两数相除,而且规定我们不能用乘法,除法和取余操作,那么我们还可以用另一神器位操作Bit Operation,比如20/

2017-08-12 15:47:39 194

原创 [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:[ "((()))", "(()())", "(())()",

2017-08-11 19:07:36 193

原创 [leetcode] 19. Remove Nth Node From End of Lis

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

2017-08-11 17:17:21 171

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

2017-08-10 18:43:32 249

原创 struts2工作流程

1.客户端发出一个HttpServletRequest请求,这个请求经过一系列的过滤器Filter(如ActionContextCleanUp等),这些过滤器最终会调用FilterDispatcher类(现在是StrutsPrepareExcuteFilter)的serviceAction方法,FilterDispatcher是控制器的核心,就是MVC的struts2实现中控制层的核心2.Fi

2017-08-09 19:21:29 260

原创 [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.相同的数字连写,所表示的数等于这些数字相加得到的数,如 Ⅲ=3;2.小的数字在大的数字的右边,所表示的数等于

2017-08-09 16:21:13 171

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

2017-08-09 15:55:45 171

原创 [leetcode] 8. String to Integer (atoi)

题目:Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible

2017-08-09 14:52:03 186

原创 [leetcode] 2. Add Two Numbers

题目:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and

2017-08-08 16:51:48 207

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

2017-08-08 16:50:22 158

原创 [leetcode] 50. Pow(x, n)

题目:Implement pow(x, n).题解:可以用递归来折半计算,每次把n缩小一半,这样n最终会缩小到0,任何数的0次方都为1,这时候我们再往回乘,如果此时n是偶数,直接把上次递归得到的值算个平方返回即可,如果是奇数,则还需要乘上个x的值。还有一点需要引起我们的注意的是n有可能为负数,对于n是负数的情况,我们可以先用其绝对值计算出一个结果再取其倒数即可, pub

2017-08-08 16:46:51 207

原创 [leetcode] 49. 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"]]

2017-08-08 16:45:01 196

原创 [leetcode] 39. Combination Sum

题目:Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may b

2017-08-08 16:40:20 226

原创 [leetcode] 43. Multiply Strings

题目:Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains on

2017-08-08 16:35:16 175

原创 [leetcode] 103.Binary Tree Zigzag Level Order Traversal

题目:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Give

2017-08-05 15:02:23 184

原创 [leetcode] 258. Add Digits

题目:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2

2017-07-30 20:26:39 154

原创 [leetcode] 257. Binary Tree Paths

题目:Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->3"]

2017-07-30 20:15:56 125

原创 java中字符串相等问题

java中判断两个字符串是否相等的问题我最近刚学java,今天编程的时候就遇到一个棘手的问题,就是关于判断两个字符串是否相等的问题。在编程中,通常比较两个字符串是否相同的表达式是“==”,但在java中不能这么写。在java中,用的是equals();例:A字符串和B和字符串比较:if(A.equals(B)){}返回true 或false.String 的equa

2017-07-30 19:22:22 200

原创 [leetcode] 234. 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?题解:这道题让我们判断一个链表是否为回文链表,LeetCode中关于回文串的题共有六道,除了这道,其他的五道为Palindrome

2017-07-27 21:29:25 198

原创 [leetcode] 231. Power of Two

题目Given an integer, write a function to determine if it is a power of two.判断一个数是否是2的次方数解法一:如果一个数是2的幂,则除以2肯定能整除,最后商为1 public boolean isPowerOfTwo(int n){ if(n<=0) return false; while

2017-07-27 19:55:03 174

原创 [leetcode] 205. 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 get t.All occurrences of a character must be replaced w

2017-07-26 20:25:28 179

原创 [leetcode] 204. Count Primes

题目:Count the number of prime numbers less than a non-negative number, n.题解:这道题给定一个非负数n,让我们求小于n的质数的个数,题目中给了充足的提示,解题方法就在第二个提示埃拉托斯特尼筛法Sieve of Eratosthenes中,这个算法的过程如下图所示,我们从2开始遍历到根号n,先找到第一个质数2,

2017-07-26 19:52:57 154

原创 [leetcode] 198. House Robber

题目You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjace

2017-07-25 21:43:40 163

转载 [leetcode]175 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 examp

2017-07-24 14:53:25 229

原创 [leetcode] 172 Factorial Trailing Zeroes

题目:Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.题解:给定一个整数n,返回n!(n的阶乘)数字中的后缀0的个数。注意:你的解法应该满足多项式时间复杂度

2017-07-24 14:41:33 145

原创 [leetcode] 167.Two Sum II - Input array is sorted

题目Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the tw

2017-07-21 15:31:02 157

原创 [leetcode] 141.Linked List Cycle

题目Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?判断一个链表是否有环这道题是快慢指针的经典应用。只需要设两个指针,一个每次走一步的慢指针和一个每次走两步的快指针,如果链表里有环的话,两个指针最

2017-07-20 15:58:21 150

原创 [leetcode] 136 single number

题目:Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without us

2017-07-20 15:38:21 169

原创 图的深度优先搜索(DFS)和广度优先搜索(BFS)

1.遍历图的遍历,所谓遍历,就是对结点的访问,一个图有那么多的结点,如何遍历这些结点,需要特定的策略,一般有两种访问策略:深度优先搜索和广度优先搜索2.深度优先搜索DFS深度优先搜索,从图的任一顶点V1开始,输出顶点V1,将V1作为当前顶点,寻找当前顶点的邻接点V2,并进行如下判断:如果目前尚未输出顶点V2,则输出V2,V2成为新的当前顶点,继续这个过程;如果V2已经输

2017-07-11 16:56:37 1283

原创 基数排序

原理类似桶排序,这里总是需要10个桶,多次使用首先以个位数的值进行装桶,即个位数为1则放入1号桶,为9则放入9号桶,暂时忽视十位数例如待排序数组[62,14,59,88,16]简单点五个数字分配10个桶,桶编号为0-9,以个位数数字为桶编号依次入桶,变成下边这样|  0  |  0  | 62 |  0  | 14 |  0  | 16 |  0  |  88 | 59 |

2017-07-10 17:07:49 126

原创 快速排序

假设我们现在对“6 1 2 7 9 3 4 5 10 8”这个10个数进行排序。首先在这个序列中随便找一个数作为基准数(不要被这个名词吓到了,就是一个用来参照的数,待会你就知道它用来做啥的了)。为了方便,就让第一个数6作为基准数吧。接下来,需要将这个序列中所有比基准数大的数放在6的右边,比基准数小的数放在6的左边,类似下面这种排列:3 1 2 5 4 6 9 7 10 8

2017-07-09 16:51:54 179

原创 KMP 字符串模式匹配算法

1.一般字符串匹配过程传统匹配思想是,从目标串Target的第一个字符开始扫描,逐一与模式串的对应字符进行匹配,若该组字符匹配,则检测下一组字符,如遇失配,则退回到Target的第二个字符,重复上述步骤,直到整个Pattern在Target中找到匹配,或者已经扫描完整个目标串也没能够完成匹配为止。     这样的算法理解起来很简单,实现起来也容易,但是其中包含了过多不必要的操作,也就是在目

2017-07-08 15:02:25 1924

转载 B树插入删除操作

插入想想2-3树的插入。2-3树结点的最大容量是2个元素,故当插入操作造成超出容量之后,就得分裂。同样m-阶B树规定的结点的最大容量是m-1个元素,故当插入操作造成超出容量之后也得分裂,其分裂成两个结点每个结点分m/2个元素。(副作用是在其父结点中要插入一个中间元素,用于分隔这两结点。和2-3树一样,再向父结点插入一个元素也可能会造成父结点的分裂,逐级向上操作,直到不再造成分裂

2017-07-07 11:02:58 2351 1

空空如也

空空如也

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

TA关注的人

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