
leetecode experience
运猫
唯一能够阻止你前进的人就是你自己。
展开
-
leetcode经验
从今天开始进行leetcode之旅。古语有云“学以致用”,尤其适合于coding,因为很多时候都是学会了不一定会用,会用了不一定知道在哪用。而算法与数据结构又是coding的核心,更是面试的重灾区。leetcode是一个非常好的深入enhance算法与数据结构的地方,我们不能单纯为了面试而刷题,这并不利于职业发展;但也不能不有所准备,面试又有其独有的特点。面试并不同于平常编程,有IDE有Google原创 2016-09-12 16:25:18 · 531 阅读 · 0 评论 -
[LeetCode]Next Permutation
Next Permutation原创 2016-10-08 20:08:54 · 219 阅读 · 0 评论 -
[LeetCode]ZigZag Conversion
[LeetCode]ZigZag Conversion原创 2016-09-20 16:07:28 · 291 阅读 · 0 评论 -
[LeetCode]Longest Substring Without Repeating Characters
[LeetCode]Longest Substring Without Repeating Characters原创 2016-09-16 19:26:50 · 457 阅读 · 0 评论 -
[LeetCode]Two Sum
这道题目本身并不难,难点在于它是我做的第一道。在此我建议大家做leetecode最好不要用IDE,从实际出发考察自己。原创 2016-09-12 16:41:07 · 385 阅读 · 0 评论 -
[LeetCode]Add Two Numbers
第二题原创 2016-09-14 20:48:45 · 277 阅读 · 0 评论 -
[LeetCode]Search in Rotated Sorted Array
Search in Rotated Sorted Array原创 2016-10-09 16:57:53 · 197 阅读 · 0 评论 -
[LeetCode]Search for a Range
Search for a Range原创 2016-10-09 18:43:22 · 207 阅读 · 0 评论 -
[LeetCode]Reverse Integer
[LeetCode]Reverse Integer原创 2016-09-20 19:28:45 · 265 阅读 · 0 评论 -
[LeetCode]Search Insert Position
Search Insert Position原创 2016-10-10 16:02:54 · 167 阅读 · 0 评论 -
[LeetCode]3Sum
3Sum原创 2016-09-24 16:55:13 · 224 阅读 · 0 评论 -
[LeetCode]Count and Say
Count and Say原创 2016-10-10 18:41:00 · 199 阅读 · 0 评论 -
[LeetCode]Group Anagrams
Group Anagrams原创 2016-10-21 16:45:32 · 213 阅读 · 0 评论 -
[LeetCode]Jump Game II
Jump Game II原创 2016-10-19 17:05:04 · 271 阅读 · 0 评论 -
[LeetCode]N-Queens
N-Queens原创 2016-10-21 19:16:56 · 280 阅读 · 0 评论 -
[LeetCode]N-Queens II
Question Follow up for N-Queens problem.Now, instead outputting board configurations, return the total number of distinct solutions.本题难度Hard。 【思路】 N-Queens中返回棋盘变成了解的个数。不必多说。【代码】public class Solution原创 2016-10-22 17:31:28 · 216 阅读 · 0 评论 -
[LeetCode]Word Search
Question Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are those horizontally or verti原创 2016-11-03 17:29:04 · 169 阅读 · 0 评论 -
[LeetCode]Combinations
Question Given two integers n and k, return all possible combinations of k numbers out of 1 … n.For example, If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],转载 2016-11-03 16:06:29 · 234 阅读 · 0 评论 -
[LeetCode]Sort Colors
Question Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the inte原创 2016-11-03 21:28:17 · 168 阅读 · 0 评论 -
[LeetCode]Letter Combinations of a Phone Number
Letter Combinations of a Phone Number原创 2016-09-27 20:21:50 · 212 阅读 · 0 评论 -
[LeetCode]Maximum Subarray
Question 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,原创 2016-10-24 16:19:27 · 208 阅读 · 0 评论 -
[LeetCode]Jump Game
Question 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原创 2016-10-24 16:54:57 · 194 阅读 · 0 评论 -
[LeetCode]Combination Sum
Combination Sum原创 2016-10-12 19:23:10 · 180 阅读 · 0 评论 -
[LeetCode]Combination Sum II
Combination Sum II原创 2016-10-13 21:24:49 · 188 阅读 · 0 评论 -
[LeetCode]Subsets
Question Given 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:[ [3], [1],原创 2016-11-03 19:24:14 · 171 阅读 · 0 评论 -
[LeetCode]Simplify Path
QuestionGiven an absolute path for a file (Unix-style), simplify it.For example, path = “/home/”, => “/home” path = “/a/./b/../../c/”, => “/c”本题难度Medium。【复杂度】 时间 O(N) 空间 O(N) 【思路】 思路很简单,先将整个路径按照/转载 2016-11-04 15:39:52 · 179 阅读 · 0 评论 -
[LeetCode]Remove Duplicates from Sorted Array II
QuestionFollow up for “Remove Duplicates”: What if duplicates are allowed at most twice?For example, Given sorted array nums = [1,1,1,2,2,3],Your function should return length = 5, with the first fiv原创 2016-11-04 16:41:30 · 176 阅读 · 0 评论 -
[LeetCode]Remove Nth Node From End of List
Remove Nth Node From End of List原创 2016-09-28 17:16:32 · 208 阅读 · 0 评论 -
(重点)[LeetCode]Longest Valid Parentheses
Longest Valid Parentheses原创 2016-10-07 16:45:44 · 271 阅读 · 0 评论 -
[LeetCode]Spiral Matrix
Question 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 ]]Yo原创 2016-10-25 16:01:00 · 211 阅读 · 0 评论 -
[LeetCode]Merge Intervals
Question本题难度Hard。排序+双指针【复杂度】 时间 O(Nlog(N)) 空间 O(N) 【思路】 先按照每个元素的start从小到大进行排序。然后利用双指针法,设置区间(low,high),如果新的元素i的start要大于high,说明(low,high)没有overlap,就将(low,high)放入结果中,然后将双指针移动:low=i.start;high=i.end;否原创 2016-10-25 17:16:00 · 297 阅读 · 0 评论 -
[LeetCode]Search in Rotated Sorted Array II
Question 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 is in th原创 2016-11-05 16:50:31 · 202 阅读 · 0 评论 -
[LeetCode]Remove Duplicates from Sorted List II
Question 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. Given原创 2016-11-05 19:17:50 · 274 阅读 · 0 评论 -
[LeetCode]Remove Duplicates from Sorted List
Question Given a sorted linked list, delete all duplicates such that each element appear only once.For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3.Subscribe to see which原创 2016-11-05 21:11:32 · 202 阅读 · 0 评论 -
[LeetCode]Merge Two Sorted Lists
Question: 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.本题难度easy,关键在于别想复杂了。题目是有assumption的:sort都是从小到大。原创 2016-09-29 15:28:48 · 233 阅读 · 0 评论 -
[LeetCode]Generate Parentheses
Generate Parentheses原创 2016-09-29 17:01:05 · 210 阅读 · 0 评论 -
[LeetCode]Insert Interval
Question 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.原创 2016-10-25 19:15:36 · 207 阅读 · 0 评论 -
[LeetCode]Length of Last Word
Question 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原创 2016-10-26 15:20:40 · 200 阅读 · 0 评论 -
[LeetCode]Merge k Sorted Lists
Question: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.本题难度为hard。原创 2016-09-30 19:39:56 · 271 阅读 · 0 评论 -
[LeetCode]Delete Node in a BST
Question Delete a node in a BST.Basically, the deletion can be divided into two stages:Search for a node to remove. If the node is found, delete the node. Example:root = [5,3,6,2,4,null,7]key = 3原创 2016-11-07 16:34:40 · 727 阅读 · 0 评论