自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

渣渣

一个IT愤青的自我告白

  • 博客(38)
  • 资源 (1)
  • 收藏
  • 关注

原创 LeetCode Search in Rotated Sorted Array II

题目:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed?Would this affect the run-time complexity? How and why?Write a function to determine if a given target

2015-12-30 19:44:28 260

原创 LeetCode Search in Rotated Sorted Array

题目:Suppose a sorted array 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. If found in the ar

2015-12-30 17:31:32 271

原创 LeetCode Game of Life

题目:According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970."Given a boar

2015-12-29 21:32:40 381

原创 LeetCode Search for a Range

题目:Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is n

2015-12-29 10:16:55 329

原创 LeetCode 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.题意:这题是之前的那题的升华,首先这类题是不能用排序来做的,因为已经写了时间

2015-12-28 21:11:10 371

原创 LeetCode Find Minimum in Rotated Sorted Array II

题目:Suppose a sorted array 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).Find the minimum element.The array may contain duplica

2015-12-28 09:23:42 231

原创 LeetCode Find Minimum in Rotated Sorted Array

题目:Suppose a sorted array 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).Find the minimum element.You may assume no duplicate e

2015-12-27 17:09:26 342

原创 LeetCode Spiral Matrix II

题目:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix:[ [ 1, 2, 3 ], [ 8, 9

2015-12-27 15:20:40 316

原创 LeetCode Spiral Matrix

题目:Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You should return [1,2,3,6,9,8,7,4,5].题意:就是给定一个m * n的矩阵,然后按照顺时针的顺序依次把所有矩阵中的元素都输入到一个list中。此题,我想到的是采用一个方法,然后这个方

2015-12-27 13:28:14 293

原创 LeetCode Search a 2D Matrix II

题目:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Int

2015-12-26 14:32:04 295

原创 LeetCode Search a 2D Matrix

题目:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first intege

2015-12-26 13:31:42 220

原创 LeetCode Merge Intervals

题目:Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].题意:就是给一个list,然后里面存放的是数据的起始位置和结束位置,并且这两个位置

2015-12-23 11:05:32 288

原创 K Sum

这是一个系列的题目,在LeetCode上都有,首先是2Sum,也就是最简单的题目。题目如下:Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the

2015-12-22 12:05:23 289

原创 LeetCode 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. 题意:将一个复杂单链表进行复制,注意:是复制,

2015-12-21 11:31:46 347

转载 LeetCode 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

2015-12-21 09:51:53 360

原创 LeetCode H-index and H-index II

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

2015-12-18 14:38:25 380

原创 LeetCode Valid Sudoku

题目:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partia

2015-12-18 10:31:54 286

原创 LeetCode 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,表示从右边开始走,然后将右

2015-12-17 21:00:20 289

原创 LeetCode 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}, reord

2015-12-17 14:48:47 240

原创 LeetCode Linked List Cycle II

题目:Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Note: Do not modify the linked list.题意:给定一个单链表,首先判断是否存在环,如果有环,那么就输出环开始的那个节点,如果没有环,那么就直接输

2015-12-17 10:41:52 258

原创 LeetCode Sort List

题目:Sort a linked list in O(n log n) time using constant space complexity.题意:用O(nlogn)的时间复杂度和一个O(1)的空间复杂度来对一个单链表进行排序。题解:因为对时间复杂度和空间复杂度都有要求,对照了各种排序算法,发现只有归并排序才能满足题目的要求。所以考虑用归并排序来做。首先就要了解什么

2015-12-16 20:25:16 312

原创 LeetCode Insertion Sort List

题目:Sort a linked list using insertion sort.题意:用插入排序将一个单链表的元素排序。题解:首先得明白什么是插入排序?有一个已经有序的数据序列,要求在这个已经排好的数据序列中插入一个数,但要求插入后此数据序列仍然有序,这个时候就要用到一种新的排序方法——插入排序法,插入排序的基本操作就是将一个数据插入到已经排好序的有序数据

2015-12-16 15:00:28 246

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

2015-12-14 15:33:39 289

原创 LeetCode 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.Gi

2015-12-14 12:56:32 391

原创 LeetCode 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 o...

2015-12-12 15:44:40 339

原创 LeetCode Convert Sorted List to Binary Search Tree

题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.题意:就是给定一个已经排好序的单链表,然后将这个单链表生成一棵平衡的二叉搜索树。题解:首先,根据可以利用之前做过的给定一个排好序的数组,然后来构造平衡的

2015-12-11 11:32:21 262

原创 LeetCode Lowest Common Ancestor of a Binary Tree

题目:Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between

2015-12-11 10:51:45 274

原创 LeetCode Count Complete Tree Nodes

题目:Given a complete binary tree, count the number of nodes.Definition of a complete binary tree from Wikipedia:In a complete binary tree every level, except possibly the last, is completel

2015-12-09 22:33:05 242

原创 LeetCode Serialize and Deserialize Binary Tree

题目:Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection l

2015-12-09 16:13:43 271

原创 LeetCode Nim Game

题目:You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone wi

2015-12-06 22:19:29 273

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

2015-12-06 15:54:21 293

原创 LeetCode Populating Next Right Pointers in Each Node I and II

题目:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point to its next rig

2015-12-06 15:19:47 266

转载 LeetCode Unique Binary Search Trees

题目:Given n, how many structurally unique BST’s (binary search trees) that store values 1…n?For example,Given n = 3, there are a total of 5 unique BST’s. 1 3 3 2

2015-12-05 16:42:20 226

原创 LeetCode Binary Tree Right Side View

题目:Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following binary tree

2015-12-05 15:55:09 339

原创 LeetCode Convert Sorted Array to Binary Search Tree

题目:Given an array where elements are sorted in ascending order, convert it to a height balanced BST.题意:就是给一个递增序列的数组,然后将这个数组转化成一棵平衡的二叉搜索树。题解:首先因为是递增的序列,所以很容易想到二分搜索来做,也就是折半查找,因为这样就可以保证是一棵平衡的

2015-12-05 13:45:15 296

原创 LeetCode Binary Search Tree Iterator

题目:Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.Calling next() will return the next smallest number in the BST.Not

2015-12-04 10:38:23 230

原创 LeetCode Kth Smallest Element in a BST

题目:Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.Note: You may assume k is always valid, 1 ≤ k ≤ BST's total elements.What if the BS

2015-12-03 21:47:28 293

原创 LeetCode Flatten Binary Tree to Linked List

题目:Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should look like:

2015-12-01 23:09:15 268

开发Struts应用的步骤及中文乱码处理.doc

这个是一个关于Struts1.x的中文乱码的处理文档,可以帮助我们有效地处理中文乱码问题。

2015-07-04

空空如也

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

TA关注的人

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