LeetCode 400题目 Java版本 (LeetCode is the platform to help you enhance your skills, expand your knowledge and prepare for technical interviews.)
2019-12-21 20:30:03 2.34MB Leetcode
1
LeetCode 完整版题解(含代码,高清PDF),找工作以及招聘的人以及ACM新手必备刷题攻略
2019-12-21 20:29:15 1.54MB LeetCode
1
LeetCode全部题目和详细解答 数据结构算法 程序员面试求职必备
2019-12-21 20:23:01 1.03MB LeetCode 数据结构算法
1
该文档是leetcode题解的java版本,解题思路巧妙,整体风格一致,编写下载,学习以及打印
2019-12-21 20:15:53 54KB leetcode java题解
1
对即将找工作的大学生,研究生都爱刷leetcode的题目,但是刚刚接受无法适从,或是一时半会儿想不到解法,没关系,leetcode题解PDF可一带你慢慢了解思路过程。
目录3.4 Add binary615.1.5 Binary Tree Level Or-3.5 Longest Palindromic Substring. 62der traversal il3.6 Regular Expression Matching665.1.6 Binary Tree Zigzag3.7 Wildcard Matching67Level Order traversal. 963.8 Longest Common Prefix5.1.7 Recover Binary Search3. 9 Valid Number70Tree983.10 Integer to roman725. 1. 8 Same Tree3. 11 Roman to Integer5.1.9 Symmetric Tree1013.12 Count and Say745.1.10 Balanced Binary Tree.. 1023. 13 Anagrams755.1.11 Flatten Binary Tree to3. 14 Simplify Path76Linked List1033. 15 Length of Last Word775.1. 12 Populating Next RightPointers in each node ii 105第4章栈和队列7952二叉树的构建1074.1栈795.2.1 Construct Binary Tree4Valid Parentheses79from Preorder and In4.1.2 Longest valid Parenorder Traversatheses805.2.2 Construct Binary Tree4.1.3 Largest Rectangle infrom Inorder and posHistogram82torder Traversal1084.14 Evaluate reverse pol-53二叉查找树109ish notation845.3. 1 Unique Binary Search4,2队列85Trees5.3.2 Unique Binary Search第5章树86Trees li.1105.1二叉树的遍历865.3.3 Validate Binary Search5.1.1 Binary Tree PreorderTreeTraversal865.3. 4 Convert Sorted array to5.1.2 Binary Tree InorderBinary Search Treel12Traversal885.3.5 Convert Sorted List to5.1. 3 Binary Tree PostorderBinary search tree113Traversal9054二叉树的递归1155. 1. 4 Binary Tree Level Or5.4.1 Minimum Depth of Bider traversalnary lree115目录5.4.2 Maximum Depth of Bi8.32重新实现 next permunary Tree116tation1425.4.3 Path Sum117833递归.1435.4 4 Path Sum il118 8.4 Permutations II1445.4.5 Binary Tree Maximum8.4.1 next permutation... 144Path Suum119842重新实现 next permu5.4.6 Populating Next Righttation144Pointers in each node 12084.3递归1445.4.7 Sum Root to Leaf Num8.5 Combinations146bers122851递归146852迭代147第6章排序1238.6 Letter Combinations of a phone6.1 Merge Sorted Array123umber1476.2 Merge Two Sorted Lists12486.1递归1486.3 Merge k Sorted Lists124862迭代96.4 Insertion Sort List125第9章广度优先搜索1506.5 Sort list1269.1 Word Ladder1506.6 First Missing Positive1279.2 Word Ladder il..1526.7 Sort Colors289. 3 Surrounded regions154第7章查找94小结15613194.1适用场景1567.1 Search for a range131942思考的步骤.1567.2 Search Insert Position.13294.3代码模板1577. 3 Search a 2D Matrix133第10章深度优先搜索162第8章暴力枚举法13510.1 Palindrome Partitioning..1628.1 Subsets13510.2 Unique Paths1658.1.1递归1350.2.1深搜1658.1.2迭代.13710.22备忘录法.1658.2 Subsets il13810.23动规166821递归1381024数学公式167822迭代.14110.3 Unique Paths Il1688. 3 Permutations14210.3.1备忘录法1688.3.1 next permutation14210.3.2动规.169目录10.4 N-Queens16913.4 Maximal rectangle19910.5 N-Queens II17213.5 Best Time to Buy and Sell Stock10.6 Restore ip addresses17320010.7 Combination Sum17413.6 Interleaving String20110.8 Combination Sum Il17513.7 Scramble String20310.9 Generate Parentheses.17713. 8 Minimum Path Sum20810.10 Sudoku solver17813.9 Edit Distance21010.11 Word Search.18013. 10 Decode Ways.21210.12小结18113. 11 Distinct Subsequences21310.12.1适用场景1813. 12 Word Break21410.122思考的步骤18113 13 Word Break il21610.12.3代码模板183第14章图21810.12.4深拽与回溯法的区别.18414. 1 Clone Graph10.12.5深搜与递归的区别..184第15章细节实现题221第11章分治法18515.1 Reverse Integer2211.1 Pow(x, n)18515.2 Palindrome Number222qrt(x18615.3 Insert Interval223第12章贪心法18715.4 Merge Intervals22412.1 Jump game18715.5 Minimum Window Substring.. 22512.2 Jump game Il18815.6 Multiply Strings22712.3 Best Time to buy and sell stock 19015.7 Substring with Concatenation12. 4 Best Time to buy and sell stock 191of all words23012. 5 Longest Substring Without re15.8 Pascal,s Trianglepeating Characters19215.9 Pascals Triangle Il23212. 6 Container with most Water. 19315.10 Spiral matrix23315.11 Spiral matrix II234第13章动态规划19515.12 ZigZag Conversion23613. 1 Triangle19515.13 Divide Two Integers23713.2 Maximum Subarray19615. 14 Text Justification23813.3 Palindrome Partitioning II19815.15 Max Points on a line目录第1章编程技巧在判断两个浮点数a和b是否相等时,不要用a=-b,应该判断二者之差的绝对值fabs(a-b)是否小于某个阈值,例如1e-9。判断一个整数是否是为奇数,用x%2!=0,不要用x%2==1,因为x可能是负数用char的值作为数组下标(例如,统计字符串中每个字符出现的次数),要考虑到char可能是负数。有的人考虑到了,先强制转型为 unsigned int再用作下标,这仍然是错的。正确的做法是,先强制转型为 unsigned char,再用作下标。这涉及C++整型提升的规则,就不详述了。以下是关于STL使用技巧的,很多条款来自《 EffectiⅤ ve StL》这本书。vector和 string优先于动态分配的数组首先,在性能上,由于 vector能够保证连续内存,因此一旦分配了后,它的性能跟原始数组相当其次,如果用new,意味着你要确保后面进行了 delete,一旦忘记了,就会岀现BUG,且这样需要都写一行 delete,代码不够短再次,声明多维数组的话,只能一个一个new,例如:int** ary = new int*[row_num];for(int i=0: i< row num; ++1)ary [i] new int [col_num]用 vector的话一行代码搞定,vector<vector<int>>ary(row_num, vector<int>(col_num, 0))使用 reserve来避免不必要的重新分配第2章线性表这类题目考察线性表的操作,例如,数组,单链表,双向链表等。21数组2.1.1 Remove Duplicates from Sorted array描述Given a sorted array, remove the duplicates in place such that each element appear only onceand return the new lengthDo not allocate extra space for another array, you must do this in place with constant memoryFor example, Given input array A =[1, 1, 2Your function should return length=2, and a is now [1, 2]分析无代码1/ LeetCode, Remove Duplicates from Sorted Array/时间复杂度0(n),空间复杂度0(1)class Solution tublicint removeDuplicates(int A[], int n)tlf (n==o return oint index =0:for (int i =1:i <n: i++iif (Alindex ! alidA[++index]= Alireturn index 12.1数组代码2// Leet Code, Remove Duplicates from Sorted Array//使用STL,时间复杂度0(n),空间复杂度0(1)class Solution ipublicint removeDuplicates(int A[, int n)treturn distance(A, unique(A, A n))代码3/ LeetCode, Remove Duplicates from Sorted Array/使用STL,时间复杂度0(n),空间复杂度0(1)lass Solution fublicint removeDuplicates (int A[], int n)treturn removeDuplicates(A, A +n, A)-A;template<typename InIt, typename outit>OutIt removeDuplicates(InIt first, InIt last, OutIt output)thile (first last)i*output++ = *firstfirst upper_bound(first, last, *firstreturn output相关题目Remove duplicates from Sorted Array Il,见§2.1.22.1.2 Remove Duplicates from Sorted Array II描述Follow 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 should return length=5, and A is now [1, 1, 2, 2, 3分析加一个变量记录一下元素出现的次数即可。这题因为是已经排序的数组,所以一个变量即可解决。如果是没有排序的数组,则需要引入一个 hashmap来记录出现次数4第2章线性表代码1// Leet Code, Remove Duplicates from Sorted Array II/时间复杂度0(n),空间复杂度0(1)//qauthorhex108(https://github.com/hex108)class Solution tublicint removeDuplicates (int A[], int n)tlf (n <=2 return nint index =2for (int i=2: i n: 1++)if (all] ! Alindex -2])A Lindex++]= Ali]return index;代码2下面是一个更简洁的版本。上面的代码略长,不过扩展性好一些,例如将 occur<2改为ocur<3,就变成了允许重复最多3次。//LeetCode, Remove Duplicates from Sorted Array II//@author虞航仲(http://weibo.com/u/1666779725)//时间复杂度0(n),空间复杂度0(1)class Solution ipublicint removeDuplicates(int A[], int n)tmt index = ofor (intif(i>0&&i<1&&A[i]==A[i-1]&&A[i]==A[i+1])continueA lindex++]=Alireturn index;相关题目Remove Duplicates from Sorted Array,见§2.1.12.1.3 Search in Rotated Sorted Array描述Suppose a sorted array is rotated at some pivot unknown to you beforehand
2019-12-21 19:42:05 1.03MB leetcode题解
1
用Java刷算法题的常用API一览,适用于准备求职时刷leetcode、lintcode等算法题,或面试白板编程。
2019-12-21 19:40:30 75KB java 求职 算法 leetcode
1
leetcode算法题的答案PDF,C++编写的,有详细的算法逻辑分析。
2019-12-21 19:27:41 1.54MB leetcode 算法 答案
1
This eBook serves as the perfect companion to LeetCode Online Judge. Learn how to write clean code and apply these fundamentals in a real interview.
2019-12-21 19:26:09 1.67MB leetcode
1
Leetcode官方版本的解题集,非常适合刷题的时候看
2019-12-21 19:21:46 10.68MB Leetcode
1
leetcode python题解,包含大量leetcode题目的解法,源代码,python实现
Course Schedule 21.4.4Number of islands14.5HeapsMerge K Sorted Linked Lists1.5.1Kth Largest Element in an Array1.5.2Arrays1.62sum‖l1.62SumⅢ1.6.2Contains Duplicate1.6.3Rotate Array1.643 Sum Smaller1.653 Sum closest1.663 Sum1.6.7Two Sum1.68Plus One1.6.9Best Time to Buy and Sell Stock1.6.10Shortest word distance1.6.11Move zeroes1.6.12Contains Duplicate1.6.13Majority Element1.6.14Remove Duplicates from Sorted Array1.6.15Nested List Weight Sum1.6.16Nested List Weighted Sum Il1.6.17Remove element1.6.18Intersection of Two Arrays ll1.6.19Merge Sorted Arrays1.6.20Reverse Vowels of a String1.6.21Intersection of Two Arrays1.6.22Container with most water1.6.23Product of Array Except Self1.6.24Trapping Rain Water1.6.25Maximum Subarray1.6.26Best Time to Buy and Sell Stock Il1.6.27Find Minimum in Rotated Sorted Array1.6.28Pascal's Triangle1.6.29Pascal's Triangle‖l1.6.30Summary Ranges1.6.31Missing Number1.6.32StringsValid Anagram1.7.1Valid palindrome1.7.2Word Pattern1.7.3Valid Parentheses1.7.4Isomorphic Strings1.7.5Reverse String1.7.6Bit ManipulationSum of Two Integers18.1Single Number18.2Single number‖18.3Single Number Ill1.8.4Maths1.9Reverse Integer1.9.1Palindrome number19.2Pow(x, n)19.3Subsets1.94Subsets‖195Fraction to Recurring Decimal19.6Excel sheet column number19.7Excel sheet column title19.8Factorial Trailing zeros199Happy Number1.9.10Count primes1.9.11Plus one19.12Divide Two Integers19.13Multiply Strings1.9.14Max Points on a line1.9.15Product of Array Except Self19.16Power of three19.17Integer Break1.9.18Power of four9.19Add digits1.9.20Ugly Number1.9.21gly Number ll1.9.22Super Ugly Number19.23Find K pairs with smallest sums1.924Self Crossing1.9.25Paint fence1.9.26Bulb switcher19.27Nim game1.9.28Matrix1.10Rotate Image1.10.1Set matrix Zeroes1.10.2Search a 2D Matrix1.10.3Search a 2d Matrix l1.10.4Spiral Matrix1.10.5Spiral Matrix‖l1.10.6DesignLRU Cache1.11.1IntroductionMy Leetcode Solutions in PythonThis book will contain my solutions in Python to the leetcode problems. Currently,will just try to post the accepted solutions. The plan is to eventually includedetailed explanations of each and every solution am doing this just for funLinked List CycleLinked List CvcleGiven a linked list, determine if it has a cycle in itFollow up: Can you solve it without using extra space?Url:https://leetcode.com/problems/linked-list-cycle/Definition for singly-linked listclass ListNode object)###def init(self, x)self, val = xself, next Noneclass Solution(object):def hasCycle(self, head)I Itype head: ListNodertype: boolII IIif head = nonereturn falseelsefast headslow= headWhile fast none and fast. next nonesloW =slow nextfast fast. next nextif fast = slow:breaki千fastNone or fast. next = nonereturn Falseelif fast = slowreturn truereturn falseLinked List CycleReverse Linked ListReverse Linked listReverse a singly linked listUrl:https://eetcode.com/problems/reverse-linked-list/definition for singly-linked list#t class ListNode(object):##def -init(self, x)self.∨al=xself next noneclass Solution(object):def reverseList(self, head)11 II l1type head: ListNodertype: ListNodeif head = nonereturn noneelif head != none and head next = nonereturn headelsetemp Nonenext node noneWhile head Nonenext node head nexthead. next temptemp= headhead next nodereturn tempDelete node in a linked listDelete node in a linked listWrite a function to delete a node(except the tail) in a singly linked list, given onlyaccess to that nodeSupposed the linked list is 1->2->3->4 and you are given the third node withvalue 3, the linked list should become 1->2->4 after calling your functionUrl:https://eetcode.com/problems/delete-node-in-a-linked-list/Definition for singly-linked listclass ListNode(object):#def -init (self, x)#self, val xself, next Noneclass solution(object):def deleteNode(self, node):I Il IItype node: ListNodertype: void Do not return anything modify node in-place insteadI 1 11f node = nonepasse⊥se:next node node. nextnode val next node valnode. next next node, next
2019-12-21 18:57:56 574KB leetcode python题解
1