- 博客(64)
- 收藏
- 关注
原创 Permutations_Leetcode_#46
1 题目 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], [
2016-09-13 11:57:30
294
原创 ump Game II_Leetcode_#45
1 题目 Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is t
2016-09-13 11:42:31
464
原创 Wildcard Matching_Leetcode_#44
1 题目 Implement wildcard pattern matching with support for ‘?’ and ‘*’.‘?’ Matches any single character. ‘*’ Matches any sequence of characters (including the empty sequence).The matching should cover
2016-09-13 11:37:28
334
原创 Trapping Rain Water_Leetcode_#42
1 题目 Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1
2016-09-13 11:29:07
287
原创 First Missing Positive_Leetcode_#41
1 题目 Given an unsorted integer array, find the first missing positive integer.For example, Given [1,2,0] return 3, and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant sp
2016-09-13 11:24:23
264
原创 Combination Sum II_Leetcode_#40
1 题目 Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C may only be used once in the combinat
2016-09-10 20:07:53
236
原创 Combination Sum_Leetcode_#39
1 题目 Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numbe
2016-09-10 20:06:39
274
原创 Soduku Solver_Leetcode_37
1 题目 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.2 解法public class Solu
2016-09-10 20:02:56
396
原创 Valid Sudoku_Leetcode_#36
1 题目 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 ‘.’.Note: A valid Sudoku boar
2016-09-10 19:59:50
278
原创 Search Insert Position_Leetcode_35
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 may assume no duplicates in the array
2016-09-10 19:55:56
263
原创 Search for a range_Leetcode_#34
1 题目 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 not found in
2016-09-10 19:53:02
214
原创 Search in Rotated Sorted Array_Leetcode_#33
1 题目 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 array return its
2016-09-10 19:48:48
221
原创 Longest Valid Parentheses_Leetcode_#32
1 题目 Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.For “(()”, the longest valid parentheses substring is “()”, whi
2016-09-10 19:47:08
288
原创 Next Permutation_Leetcode_#31
1.题目 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 possibl
2016-09-10 19:44:04
227
原创 Divide Two Integers_Leetcode_#29
1 题目 Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.2 解法public class Solution { public int divide(int dividend, int divisor) {
2016-08-18 21:43:00
259
原创 Implement strStr()_Leetcode_#28
1 题目 Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.2 解法public class Solution { public int strStr(String haystack, St
2016-08-18 21:41:58
236
原创 Remove Duplicates from sorted Array_Leetcode_#26
1 题目 Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place wit
2016-08-16 21:38:30
221
原创 Reverse Nodes in k-Group_Leetcode_#25
1 题目 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 i
2016-08-16 21:25:40
260
原创 Swap Nodes in Pairs_Leetcode_#24
1 题目 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 only constant space. You
2016-08-15 20:01:37
229
原创 Merge k sorted Lists_Leetcode_#23
1 题目 Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.2 解法 思路:二分法 时间复杂度:O(N*Lg(M)),N是lists最大长度,M是lists大小。/** * Definition for singly-linked list. *
2016-08-15 20:00:09
293
原创 Generate Parentheses_Leetcode_#22
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:[ “((()))”, “(()())”, “(())()”, “()(
2016-08-15 19:57:33
230
原创 Merge Two Sorted Lists_Leetcode_#21
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.2.解法/** * Definition for singly-linked list. * publi
2016-08-15 19:55:14
220
原创 Valid Parentheses_Leetcode_#20
1.题目 Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets must close in the correct order, “()” and “()[]{}” are all valid
2016-08-14 18:55:59
307
原创 Remove Nth Node From End of List_Leetcode_#19
1.题目 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 end, the linked l
2016-08-14 17:19:59
233
原创 4Sum_Leetcode_#18
1.题目 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: The solution
2016-08-14 16:36:42
232
原创 3Sum Closest_Leetcode_#16
1.题目 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 have ex
2016-08-14 11:45:24
243
原创 3Sum_Leetcode_#15
1.题目 Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain
2016-08-14 10:59:06
198
原创 Longest common prefix_Leetcode_#14
1.题目 Write a function to find the longest common prefix string amongst an array of strings.2.解法 思路:先求得字符串数组中的最小长度minLen,最大的公共前部的长度为minLen,最多遍历字符串数组MinLen次即可。 遍历一次,中间遇到有不相同的就立即返回结果。public class Solut
2016-08-13 20:48:52
185
原创 Container with most water_Leetcode_#11
1.题目 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, 0). Find t
2016-08-13 19:58:52
286
原创 String to Integer_Leetcode_#8
1.题目 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 input c
2016-08-13 16:08:04
220
原创 Palindrome Number_Leetcode_#9
1.题目 Determine whether an integer is a palindrome. Do this without extra space.2.解法 思路:类似于翻转一个数,定义一个y,从个位开始,取该位的数字,y = y*10 + x1%10。最后比较y与x是否相等。 时间复杂度:O(N) public class Solution { public boo
2016-08-13 16:03:37
232
原创 Reverse digits of an integer_Leetcode_#7
1.题目 Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321 2.解法 思路:考虑溢出的情况 时间复杂度O(N)public class Solution { public int reverse(int x){ boolean bPos
2016-08-13 10:09:10
306
原创 Zigzag Conversion_Leetcode_#6
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 font for better legibility)P A H N A P L S
2016-08-13 10:05:43
288
原创 Longest Palindromic Substring_Leetcode_#5
1.题目 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.2.解法 思路:从数组开始处作为起点,并
2016-08-13 09:56:17
276
原创 Struts2学习小结
0.前言 最近在看SSH框架,一边学习一边总结,记录在博客上,以加深理解和以后的回顾。1.概念 采用Java Servlet/Jsp技术,是一个实现基于MVC设计模式的Web应用框架,在MVC设计模式中,Struts2被作为控制器来建立模型和视图的数据交互。2.工作原理 一个客户请求在Struts2框架中处理的过程大概有以下几个步骤: (1)客户提交请求到服务器; (2)请求被提
2016-08-10 16:00:40
466
原创 Median of Two Sorted Arrays_leetcode_#4
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 complexity should be O(log (m+n)).Example 1: nums1 = [1, 3
2016-08-09 22:17:17
294
原创 Longest Substring Without Repeating Characters_leetcode_#3
1.题目 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 answer is “b”, with
2016-08-08 23:25:24
209
原创 Add Two Numbers_leetcode_#2
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 single digit. Add the two numbers and return it as a
2016-08-07 11:14:38
248
原创 Two Sum_leetcode_#1
0.题记 Bob今天开始要强势回归Leetcode刷题啦撒花撒花LOL。 作为一名即将研二的学生党,正式开始了实习狗的生涯,平时加班不多,正是刷题解闷的大好机会啊O(∩_∩)O哈哈~ 给自己定个刷题计划吧: 第一阶段(2个月):从今天8月6号开始到10月6号,按照leetcode上面题目顺序从第1题开始刷,完成100题,每题刷完都写到CSDN博客上面。
2016-08-06 16:50:00
260
原创 Find Peak Element
题目:A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple p
2015-01-31 09:13:41
517
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人