1. 题目 Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 对matrixi==…
分类:LeetCode
LeetCode | Populating Next Right Pointers in Each Node II(将每一层链接成一个链表)
Follow up for problem “Populating Next Right Pointers in Each Node“. What if the given tree could …
Merge Intervals 解题报告
题目: Given a collection of intervals, merge all overlapping intervals. For example, Given [1,3],[2,6],[8,10],[1…
path sum
描述: Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the v…
740. Delete and Earn
Medium 思路参考House Rubbery和Gas station,之前我纠结重复的数字怎么处理,结果很简单。维持一个数组,以num为index,值为该num拥有的总points数。多次遇到就多次加就好了。 cla…
309. 最佳买卖股票时机含冷冻期
题目分析 这个题目的题眼在于状态转换的比较多. 我认为最好的一种解法是使用了三个一维DP数组维护状态. buy_dp sell_dp cool_dp 使用了三个一维DP数组的好处 空间换复杂度, 更多的空间, 可以使我们…
[LeetCode By Go 100]26. Remove Duplicates from Sorted Array
题目 Given a sorted array, remove the duplicates in place such that each element appear only once and return the…
[LeetCode] Count and Say 计数和读法
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ..…
[LeetCode] Second Minimum Node In a Binary Tree 二叉树中第二小的结点
Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node …
[LeetCode] Custom Sort String 自定义排序的字符串
S and T are strings composed of lowercase letters. In S, no letter occurs more than…
力扣(LeetCode)377
题目地址:https://leetcode-cn.com/probl…题目描述:在上次打劫完一条街道之后和一圈房屋后,小偷又发现了一个新的可行窃的地区。这个地区只有一个入口,我们称之为“根”。 除了“根”之外…
LeetCode 4Sum 解题报告
其思路类似于3sum。下面是题目和代码。 Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + …