作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 日期 题目地址:https://leetcode.com/problems/image-overlap/description/ 题目描述 Two images A and B are given, represented as binary, square matrices of the same size. (A binary matrix ha…
[LeetCode]120. Triangle 解题报告(Python) 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址https://leetcode.com/problems/triangle/description/ 题目描述: Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjac…
LeetCode 1 Two Sum 解题报告 偶然间听见leetcode这个平台,这里面题量也不是很多200多题,打算平时有空在研究生期间就刷完,跟跟多的练习算法的人进行交流思想,一定的ACM算法积累可以对以后在对算法中优化带来好处.Ok,今天是我做的第一题Add Two Sum. 题目要求 Given an array of integers, find two numbers such that they add up to a specific target number. The fu…
[题目] Given a collection of numbers that might contain duplicates, return all possible unique permutations. For example, [1,1,2] have the following unique permutations: [1,1,2], [1,2,1], and [2,1,1]. [解析] 题意:求一个数组的全排列.与[LeetCode]Permutations 解题报告 不同的是…
[LeetCode]Island Perimeter 解题报告 [LeetCode] https://leetcode.com/problems/island-perimeter/ Total Accepted: 16143 Total Submissions: 28552 Difficulty: Easy Question You are given a map in form of a two-dimensional integer grid where 1 represents land…
[LeetCode]01 Matrix 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/01-matrix/#/description 题目描述: Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance between two adjacent cells is 1. Example:…
[LeetCode]Largest Number 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/largest-number/#/description 题目描述: Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], t…
[LeetCode]Gas Station 解题报告 标签(空格分隔): LeetCode 题目地址:https://leetcode.com/problems/gas-station/#/description 题目描述: There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tan…
Unique Paths II Total Accepted: 31019 Total Submissions: 110866My Submissions Question Solution  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 spa…
Distinct Subsequences Total Accepted: 38466 Total Submissions: 143567My Submissions Question Solution  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 fro…
[题目] Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution. For example, given array S = {…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/rectangle-overlap/description/ 题目描述: A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bottom-left corner, and (…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:DFS 方法二:迭代 日期 [LeetCode] 题目地址:https://leetcode.com/problems/binary-tree-level-order-traversal-ii/ Total Accepted: 55876 Total Submissions: 177210 Difficulty: Easy 题目描述 Given…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 迭代 递归 日期 [LeetCode] 题目地址:https://leetcode.com/problems/reverse-linked-list/ Total Accepted: 105474 Total Submissions: 267077 Difficulty: Easy 题目描述 Reverse a singly linked list.…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 双指针 日期 [LeetCode] https://leetcode.com/problems/remove-duplicates-from-sorted-array/ Total Accepted: 129010 Total Submissions: 384622 Difficulty: Easy 题目描述 Given a sorted array…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 单调递减栈 日期 题目地址:https://leetcode.com/problems/next-greater-node-in-linked-list/ 题目描述 We are given a linked list with head as the first node. Let's number the nodes in the list: no…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 递归 迭代 日期 题目地址:https://leetcode.com/problems/binary-tree-inorder-traversal/ 题目描述 Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 日期 题目地址:https://leetcode.com/problems/maximum-binary-tree/description/ 题目描述 Given an integer array with no duplicates. A maximum tree building on this array is defined as fol…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 回溯法 循环 日期 题目地址:https://leetcode.com/problems/letter-case-permutation/description/ 题目描述 Given a string S, we can transform every letter individually to be lowercase or uppercase…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 回溯法 日期 题目地址:https://leetcode.com/problems/subsets/description/ 题目描述 Given a set of distinct integers, nums, return all possible subsets (the power set). Note: The solution se…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 方法一:库函数 方法二:递归 方法三:回溯法 日期 题目地址:https://leetcode.com/problems/permutations/description/ 题目描述 Given a collection of distinct numbers, return all possible permutations. For example, [1,…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 DFS 日期 题目地址:https://leetcode.com/problems/minesweeper/description/ 题目描述 Let's play the minesweeper game (Wikipedia, online game)! You are given a 2D char matrix representing th…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归+队列 栈 日期 题目地址:https://leetcode.com/problems/flatten-nested-list-iterator/description/ 题目描述 Given a nested list of integers, implement an iterator to flatten it. Each element i…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 递归 迭代 日期 题目地址:https://leetcode.com/problems/n-ary-tree-preorder-traversal/description/ 题目描述 Given an n-ary tree, return the preorder traversal of its nodes' values. For example,…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 迭代 递归 日期 题目地址:https://leetcode.com/problems/reverse-linked-list-ii/description/ 题目描述 Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/description/ 题目描述 Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 迭代 日期 题目地址:https://leetcode.com/problems/delete-node-in-a-bst/description/ 题目描述 Given a root node reference of a BST and a key, delete the node with the given key in the BST. Re…
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 约瑟夫环 日期 题目地址:https://leetcode-cn.com/problems/yuan-quan-zhong-zui-hou-sheng-xia-de-shu-zi-lcof/ 题目描述 0,1,,n-1这n个数字排成一个圆圈,从数字0开始,每次从这个圆圈里删除第m个数字.求出这个圆圈里剩下的最后一个数字. 例如,0.1.2.3.4这5个…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/h-index/description/ 题目描述: Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's…
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 遍历 日期 题目地址:https://leetcode.com/problems/heaters/ 题目描述 Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the…