自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

AIpush的博客

船到桥头

  • 博客(40)
  • 收藏
  • 关注

原创 LeetCode131. Palindrome Partitioning(思路及python解法)

Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.Example:Input:"aab"Output:[ ["aa","b"], ["a","a"...

2019-12-30 15:57:17 258

原创 LeetCode79. Word Search(思路及python解法)

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 vertically n...

2019-12-29 21:54:46 281

原创 LeetCode39. Combination Sum(思路及python解法)

ShareGiven asetof candidate numbers (candidates)(without duplicates)and a target number (target), find all unique combinations incandidateswhere the candidate numbers sums totarget.Thesame...

2019-12-29 01:09:12 282

原创 LeetCode54. Spiral Matrix(思路及python解法)

Given a matrix ofmxnelements (mrows,ncolumns), return all elements of the matrix in spiral order.Example 1:Input:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]Output: [1,2,3,6,9,8,7,4,5]...

2019-12-28 16:24:21 325 1

原创 LeetCode36. Valid Sudoku(思路及python解法)

Determine if a9x9 Sudoku boardis valid.Only the filled cells need to be validatedaccording to the following rules:Each rowmust contain thedigits1-9without repetition. Each column must conta...

2019-12-27 16:38:29 215

原创 LeetCode22. Generate Parentheses(思路及python解法)

Givennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())"...

2019-12-26 21:25:45 187

原创 LeetCode15. 3Sum(思路及python解法)

Given an arraynumsofnintegers, are there elementsa,b,cinnumssuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not cont...

2019-12-26 20:59:11 297

原创 LeetCode73. Set Matrix Zeroes(思路及python解法)

Given amxnmatrix, if an element is 0, set its entire row and column to 0. Do itin-place.Example 1:Input: [ [1,1,1], [1,0,1], [1,1,1]]Output: [ [1,0,1], [0,0,0], [1,0,1]]将...

2019-12-21 15:58:32 240

原创 LeetCode56. Merge Intervals(思路及python解法)

Given a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and [2,6] overlaps...

2019-12-20 22:56:30 970

原创 LeetCode55. Jump Game(思路及python解法)

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...

2019-12-20 21:20:12 215

原创 LeetCode50. Pow(x, n)(思路及python解法)

Implementpow(x,n), which calculatesxraised to the powern(xn).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Example 3:Input: 2.00000, ...

2019-12-20 19:19:08 222

原创 LeetCode41. First Missing Positive(思路及python解法)

Given an unsorted integer array, find the smallest missingpositive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Input: [7,8,9,11,12]Outpu...

2019-12-20 18:22:50 225

原创 LeetCode49. Group Anagrams (思路及python解法)

Given an array of strings, group anagrams together.Example:Input: ["eat", "tea", "tan", "ate", "nat", "bat"],Output:[ ["ate","eat","tea"], ["nat","tan"], ["bat"]]把相同字母,不同顺序的单词放在一起。思路就...

2019-12-20 18:03:02 316

原创 LeetCode17. Letter Combinations of a Phone Number(思路及python解法)

Given a string containing digits from2-9inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is giv...

2019-12-19 23:27:49 121

原创 LeetCode34. Find First and Last Position of Element in Sorted Array (思路及python解法)

Given an array of integersnumssorted in ascending order, find the starting and ending position of a giventargetvalue.Your algorithm's runtime complexity must be in the order ofO(logn).If the...

2019-12-19 23:27:25 208

原创 LeetCode11. Container With Most Water (思路及python解法)

Givennnon-negative integersa1,a2, ...,an, where each represents a point at coordinate (i,ai).nvertical lines are drawn such that the two endpoints of lineiis at (i,ai) and (i, 0). Find two...

2019-12-19 10:54:50 209

原创 LeetCode8. String to Integer (atoi)(思路及python解法)

Implementatoiwhichconverts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from thi...

2019-12-18 22:25:11 139

原创 LeetCode48. Rotate Image(思路及python解法)

You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Note:You have to rotate the imagein-place, which means you have to modify the input 2D matrix d...

2019-12-18 21:04:23 171

原创 LeetCode230. Kth Smallest Element in a BST(思路及python解法)

Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's total elements.Example 1:Input: root = [3,1...

2019-12-18 11:44:42 277

原创 LeetCode78. Subsets(思路及python解法)

Given a set ofdistinctintegers,nums, return all possible subsets (the power set).Note:The solution set must not contain duplicate subsets.Example:Input: nums = [1,2,3]Output:[ [3], [1...

2019-12-17 21:54:29 245

原创 LeetCode238. Product of Array Except Self(思路及python解法)

Given an arraynumsofnintegers wheren> 1, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i].Example:Input: [1,2,3,4]Output: ...

2019-12-17 20:50:45 147

原创 LeetCode347. Top K Frequent Elements(思路及python解法)

Given a non-empty array of integers, return thekmost frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output: [1,2]Example 2:Input: nums = [1], k = 1Output: [1]首先是统计每个数字出...

2019-12-17 18:02:38 231

原创 LeetCode46. Permutations (思路及python解法)

Given a collection ofdistinctintegers, return all possible permutations.Example:Input: [1,2,3]Output:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]一个深度优先遍历的应用。深度优先遍历...

2019-12-17 14:14:43 324 1

原创 LeetCode412. Fizz Buzz(思路及python解法)

Write a program that outputs the string representation of numbers from 1 ton.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. Fo...

2019-12-17 11:39:36 315

原创 LeetCode617. Merge Two Binary Trees (思路及python解法)

Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.You need to merge them into a new binary tree...

2019-12-17 11:05:37 165

原创 LeetCode299. Bulls and Cows(思路及python解法)

You are playing the followingBulls and Cowsgame with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint tha...

2019-12-16 23:13:44 560 1

原创 LeetCode130. Surrounded Regions (思路及python解法)

Given a 2D board containing'X'and'O'(the letter O), capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region.Example:X X X XX O O...

2019-12-16 16:36:50 244

原创 LeetCode200. Number of Islands (思路及python解法)

Given 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 horizontally or vertically. You may assume...

2019-12-16 15:50:17 208

原创 LeetCode129. Sum Root to Leaf Numbers (思路及python解法)

Given a binary tree containing digits from0-9only, each root-to-leaf path could represent a number.An example is the root-to-leaf path1->2->3which represents the number123.Find the tota...

2019-12-10 22:26:23 162

原创 LeetCode117. Populating Next Right Pointers in Each Node II(思路及python解法)

Given a binary treestruct Node { int val; Node *left; Node *right; Node *next;}Populate each next pointer to point to its next right node. If there is no next right node, the next point...

2019-12-10 20:18:11 206

原创 LeetCode116. Populating Next Right Pointers in Each Node(思路及python解法)

You are given aperfect binary treewhereall leaves are on the same level, and every parent has two children. The binary tree has the following definition:struct Node { int val; Node *left; ...

2019-12-10 19:02:22 214

原创 LeetCode113. Path Sum II (思路及python解法)

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Note:A leaf is a node with no children.Example:Given the below binary tree andsum = 22,...

2019-12-10 16:33:35 133

原创 LeetCode105. Construct Binary Tree from Preorder and Inorder Traversal (思路及python解法)

Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, givenpreorder =[3,9,20,15,7]inorder = [9,3...

2019-12-10 12:02:33 276

原创 LeetCode106. Construct Binary Tree from Inorder and Postorder Traversal (思路及python解法)

Given inorder and postorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.For example, giveninorder =[9,3,15,20,7]postorder = [9...

2019-12-10 12:01:28 209

原创 LeetCode104. Maximum Depth of Binary Tree (思路及python解法)

Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note:A leaf is a node with no childre...

2019-12-09 22:38:59 201

原创 LeetCode210. Course Schedule II (思路及python解法)

There are a total ofncourses you have to take, labeled from0ton-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair...

2019-12-03 18:22:34 262

原创 LeetCode207. Course Schedule (思路及python解法)

There are a total ofncourses you have to take, labeled from0ton-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair...

2019-12-03 17:58:21 374

原创 LeetCode559. Maximum Depth of N-ary Tree (思路及python解法)

Given a n-ary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Nary-Tree input serializationis repres...

2019-12-02 23:18:47 240

原创 LeetCode200. Number of Islands (思路及python解法)

Given 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 horizontally or vertically. You may assume...

2019-12-02 10:03:39 253

原创 LeetCode199. Binary Tree Right Side View (思路及python解法)

Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.Example:Input:[1,2,3,null,5,null,4]Output:[1, 3, 4...

2019-12-01 20:35:11 223

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除