LeetCode
文章平均质量分 77
jingxichen_
这个作者很懒,什么都没留下…
展开
-
leetCode---Maximum Subarray
一. 题目:Maximum SubarrayFind 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 conti原创 2017-02-23 20:23:10 · 179 阅读 · 0 评论 -
leetCode---Remove Duplicates from Sorted Array II
一. 题目:Remove Duplicates from Sorted Array II Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, given sorted arrayA = [1,1,1,2,2,3], your fun原创 2017-06-13 10:26:04 · 136 阅读 · 0 评论 -
leetCode---Search a 2D Matrix II
一. 题目:Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, given sorted array A = [1,1,1,2,2,3], your function原创 2017-06-20 11:15:48 · 141 阅读 · 0 评论 -
leetCode---Majority Element
一. 题目:Majority Element Given an array of sizen, find the majority element. The majority element is the element that appearsmore than⌊ n/2 ⌋ times.You may assume that the array is原创 2017-03-04 20:34:06 · 260 阅读 · 0 评论 -
leetCode---Range Sum Query - Immutable
一. 题目:Remove Duplicates from Sorted Array II Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, given sorted arrayA = [1,1,1,2,2,3], your原创 2017-06-15 11:06:26 · 137 阅读 · 0 评论 -
leetCode---Invert Binary Tree
一. 题目:Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontall原创 2017-06-22 10:58:56 · 145 阅读 · 0 评论 -
leetCode---Symmetric Tree
一. 题目:Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontall原创 2017-06-21 10:39:06 · 144 阅读 · 0 评论 -
leetCode---Arithmetic Slices
一. 题目:Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontall原创 2017-06-21 21:26:55 · 179 阅读 · 0 评论 -
leetCode--- Is Subsequence
一. 题目:Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontall原创 2017-06-25 21:02:06 · 160 阅读 · 0 评论 -
leetCode--- Jump Game II
一. 题目:Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontall原创 2017-06-22 11:30:00 · 127 阅读 · 0 评论 -
leetCode---Gas Station
一. 题目:Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontall原创 2017-06-27 22:22:47 · 222 阅读 · 0 评论 -
leetCode---Candy
一. 题目:Remove Duplicates from Sorted Array IIFollow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, given sorted array A = [1,1,1,2,2,3], your原创 2017-06-20 11:47:14 · 141 阅读 · 0 评论 -
leetCode--- Patching Array
一. 题目:Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontall原创 2017-06-26 15:28:07 · 150 阅读 · 0 评论 -
leetCode---Minimum Size Subarray Sum
一. 题目:Number of IslandsGiven a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontall原创 2017-06-25 20:36:16 · 212 阅读 · 0 评论 -
leetCode---Number of Islands
一. 题目:Remove Duplicates from Sorted Array II test01二. 思路分析 段落儿原创 2017-06-15 10:15:24 · 159 阅读 · 0 评论 -
leetCode---Assign Cookies
一. 题目:Remove Duplicates from Sorted Array II Follow up for "Remove Duplicates": What if duplicates are allowed at most twice?二. 思路分析 因为题目是所给数组已经排序的数组,所以加一个变量记录一下元素出现的次数,这样加一个变量即可解决原创 2017-06-15 09:51:11 · 122 阅读 · 0 评论 -
leetCode---Merge k Sorted Lists
一. 题目:Merge k Sorted ListsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.二. 思路分析借鉴归并排序的方法,自顶向下,先递归的对链表的前半部分和后半部分进行归并排序,最后再m原创 2017-04-19 11:00:03 · 134 阅读 · 0 评论 -
leetCode---Remove Nth Node From End of List
一. 题目:Remove Nth Node From End of List 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 r原创 2017-04-18 22:03:14 · 180 阅读 · 0 评论 -
leetCode---3Sum Closest
一. 题目:3SumGiven an array S of n integers, find three integers inS such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input wou原创 2017-04-07 15:30:32 · 202 阅读 · 0 评论 -
leetCode---3Sum
一. 题目:3SumGiven an array S of n integers, are there elementsa, 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原创 2017-04-07 15:04:56 · 141 阅读 · 0 评论 -
leetCode---Target Sum
一. 题目:Target SumYou are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols+ and-. For each integer, you should choose one from+ and- as its new s原创 2017-03-11 23:27:49 · 288 阅读 · 0 评论 -
leetCode---Longest Substring Without Repeating Characters
一. 题目:Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "ab原创 2017-03-27 20:53:18 · 206 阅读 · 0 评论 -
leetCode---Add Two Numbers
一. 题目:Add Two NumbersYou 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 t原创 2017-03-27 20:18:47 · 167 阅读 · 0 评论 -
leetCode---Increasing Subsequences
一. 题目:Increasing Subsequences Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should原创 2017-03-18 20:43:27 · 231 阅读 · 0 评论 -
leetCode---Rotate Array
一. 题目:Rotate Array Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note:Try to come up as ma原创 2017-05-23 21:42:18 · 177 阅读 · 0 评论 -
leetCode---Subsets
一. 题目:SubsetsGiven a set of distinct integers, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets. For example,If nums = [1,2,3], a solution is:原创 2017-04-25 21:55:30 · 141 阅读 · 0 评论 -
leetCode---Increasing Triplet Subsequence
一. 题目:test01 Follow up for "Remove Duplicates": What if duplicates are allowed at most twice?二. 思路分析 Follow up for "Remove Duplicates": What if duplicates are allowed at most twice?原创 2017-06-15 09:27:57 · 131 阅读 · 0 评论 -
leetCode---Reverse Words in a String III
一. 题目:Reverse Words in a String IIIGiven a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.Example原创 2017-06-04 18:19:09 · 158 阅读 · 0 评论 -
leetCode---Array Partition I
一. 题目:Array Partition IGiven an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for原创 2017-06-04 17:52:36 · 179 阅读 · 0 评论 -
leetCode---Intersection of Two Arrays
一. 题目:Intersection of Two ArraysIntersection of Two Arrays IGiven two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].原创 2017-05-19 13:55:49 · 184 阅读 · 0 评论 -
leetCode---Valid Anagram
一. 题目:Valid AnagramGiven two strings s and t, write a function to determine if t is an anagram of s.For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.原创 2017-05-19 13:35:10 · 143 阅读 · 0 评论 -
leetCode---Container With Most Water
一. 题目:Container With Most WaterGiven 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 lin原创 2017-04-27 20:49:29 · 326 阅读 · 0 评论 -
leetCode---Implementint sqrt(int x).
一. 题目:Implementint sqrt(int x).Implementint sqrt(int x).Compute and return the square root of x.二. 思路分析 这道题很巧妙的运用了二分查找法的特性,有序,查找pos(在这道题中pos=value),找到返回pos,找不到返回原创 2017-05-09 16:30:01 · 230 阅读 · 0 评论 -
leetCode---Subsets II
一. 题目:Subsets IIGiven a collection of integers that might contain duplicates, nums, return all possible subsets.Note: The solution set must not contain duplicate subsets. For example,If nums原创 2017-04-25 22:05:36 · 286 阅读 · 0 评论