
LeetCode
小学生Jason
简简单单,认认真真。
展开
-
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 possible o原创 2015-06-15 15:40:36 · 407 阅读 · 0 评论 -
LeetCode_23---Merge k Sorted Lists
Merge k Sorted Lists Total Accepted: 44376 Total Submissions: 210473My SubmissionsQuestion Solution Merge k sorted linked lists and return it as one sorted list. Analyze and desc原创 2015-06-08 10:49:50 · 392 阅读 · 0 评论 -
LeetCode_22---Generate Parentheses
LeetCode原创 2015-06-05 17:24:02 · 350 阅读 · 0 评论 -
LeetCode_65---Valid Number
Validate if a given string is numeric.Some examples:"0" => true" 0.1 " => true"abc" => false"1 a" => false"2e10" => trueNote: It is intended for the problem statement to be ambiguous.原创 2015-06-29 11:25:03 · 393 阅读 · 0 评论 -
LeetCode_62---Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bo原创 2015-06-29 09:37:36 · 360 阅读 · 0 评论 -
LeetCode_56---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].Hide Tags Array SortCode:原创 2015-06-26 14:38:18 · 387 阅读 · 0 评论 -
LeetCode_57---Insert Interval
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Examp原创 2015-06-26 16:11:18 · 449 阅读 · 0 评论 -
LeetCode_59---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, 4 ], [原创 2015-06-27 21:26:18 · 444 阅读 · 0 评论 -
LeetCode_58---Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is def原创 2015-06-27 21:24:23 · 377 阅读 · 0 评论 -
LeetCode_53---Maximum Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] has原创 2015-06-26 09:11:21 · 434 阅读 · 0 评论 -
LeetCode_20---Valid Parentheses
LeetCode原创 2015-06-05 15:34:37 · 335 阅读 · 0 评论 -
LeetCode_19---Remove Nth Node From End of List
LeetCode原创 2015-06-05 14:26:40 · 315 阅读 · 0 评论 -
LeetCode_18---4SUM
LeetCode原创 2015-06-05 13:38:52 · 376 阅读 · 0 评论 -
LeetCode_55---Jump Game
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.Determine if yo原创 2015-06-26 13:49:37 · 335 阅读 · 0 评论 -
LeetCode_54---Spiral Matrix
Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You原创 2015-06-26 13:48:04 · 406 阅读 · 0 评论 -
LeetCode_21---Merge Two Sorted Lists
LeetCode原创 2015-06-05 16:24:54 · 331 阅读 · 0 评论 -
LeetCode_17---Letter Combinations of a Phone Number
LeetCode原创 2015-06-04 14:06:07 · 394 阅读 · 0 评论 -
LeetCode_60---Permutation Sequence
The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n = 3):"123""132""213""231""312原创 2015-06-28 10:51:52 · 407 阅读 · 0 评论 -
LeetCode_63---Unique Paths II
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid原创 2015-06-29 09:41:59 · 391 阅读 · 0 评论 -
LeetCode_30---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) in s that is a concatenation of each word in wordsexactly once and w原创 2015-06-15 13:45:49 · 398 阅读 · 0 评论 -
LeetCode_29---Divide Two Integers
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.Hide Tags Math Binary SearchCode:package From21;原创 2015-06-12 15:32:04 · 363 阅读 · 0 评论 -
LeetCode_25---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 is.原创 2015-06-10 11:43:01 · 372 阅读 · 0 评论 -
LeetCode_26---Remove Duplicates from Sorted Array
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 with原创 2015-06-11 21:04:37 · 361 阅读 · 0 评论 -
LeetCode_27---Remove Element
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.翻原创 2015-06-11 21:58:38 · 508 阅读 · 0 评论 -
LeetCode_115---Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be none)原创 2015-07-08 18:02:24 · 441 阅读 · 0 评论 -
LeetCode_69---Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x.Hide Tags Math Binary Search翻译:求平方值Code:/** * */package From61;/** * @author MohnSnow原创 2015-07-01 10:47:38 · 519 阅读 · 0 评论 -
LeetCode_71---Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner Cases:Did you co原创 2015-07-01 10:59:46 · 589 阅读 · 0 评论 -
LeetCode_70---Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Hide Tags Dynamic Programmin原创 2015-07-01 10:50:03 · 401 阅读 · 0 评论 -
LeetCode_68---Text Justification
Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified.You should pack your words in a greedy approach; that is,原创 2015-06-29 14:13:53 · 461 阅读 · 0 评论 -
LeetCode---题目难度、出题频率、数据结构、考察点统计
1Two Sum25arraysort setTwo Pointers2Add Two Numbers34linked listTwo Pointers转载 2015-05-29 11:30:17 · 1705 阅读 · 0 评论 -
LeetCode_24---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 only constant space. You m原创 2015-06-08 17:21:14 · 326 阅读 · 0 评论 -
LeetCode_64---Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at a原创 2015-06-29 11:23:35 · 336 阅读 · 0 评论 -
LeetCode_66---Plus One
Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.Hide Tags Array Math原创 2015-06-29 11:58:57 · 471 阅读 · 0 评论 -
LeetCode_61---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.Hide Tags Linked List Two Point原创 2015-06-28 11:46:40 · 389 阅读 · 0 评论 -
LeetCode_67---Add Binary
Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".Hide Tags Math String翻译:Code:/** * */package原创 2015-06-29 13:41:07 · 349 阅读 · 0 评论 -
LeetCode_50---Pow(x, n)
Implement pow(x, n).Hide Tags Math Binary Search翻译:Code:/** * */package From41;/** * @author MohnSnow * @time 2015年6月25日 上午10:41:33 *原创 2015-06-25 11:19:46 · 568 阅读 · 0 评论 -
LeetCode_52---N-Queens II
Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.Code:/** * */package From41原创 2015-06-25 17:57:31 · 410 阅读 · 0 评论 -
LeetCode_16---3Sum Closest
LeetCode原创 2015-06-04 11:45:01 · 434 阅读 · 0 评论 -
LeetCode_41---First Missing Positive
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 spa原创 2015-06-19 09:58:19 · 349 阅读 · 0 评论 -
LeetCode_38---Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as "o原创 2015-06-17 09:39:08 · 315 阅读 · 0 评论