Leetcode上新加入了剑指 offer板块,最近准备这些题重新做一遍,温故知新。后续会将所有的解题思路和代码收录到这里,并将这些题做分类,便于以后查阅。 数组 剑指 offer——数组篇 字符串 剑指 offer——字符串篇 链表、栈与队列 剑指 offer——链表、栈与队列篇 树与图 剑指 o ...
分类:
其他好文 时间:
2020-07-19 23:09:15
阅读次数:
57
https://leetcode-cn.com/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/ 1、题目描述: 输入一个整型数组,数组里有正数也有负数。数组中的一个或连续多个整数组成一个子数组。求所有子数组的和的最大值。 要求时间复杂度为O(n)。 2、示 ...
分类:
编程语言 时间:
2020-07-19 18:09:51
阅读次数:
388
package LeetCode_122 /** * 122. Best Time to Buy and Sell Stock II * https://leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/description/ * * ...
分类:
其他好文 时间:
2020-07-19 18:07:26
阅读次数:
79
Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloon ...
分类:
其他好文 时间:
2020-07-19 18:05:12
阅读次数:
68
班上有 N 名学生。其中有些人是朋友,有些则不是。他们的友谊具有是传递性。如果已知 A 是 B 的朋友,B 是 C 的朋友,那么我们可以认为 A 也是 C 的朋友。所谓的朋友圈,是指所有朋友的集合。 给定一个 N * N 的矩阵 M,表示班级中学生之间的朋友关系。如果M[i][j] = 1,表示已知 ...
分类:
其他好文 时间:
2020-07-19 18:01:56
阅读次数:
66
问题描述 给定一个可包含重复数字的序列,返回所有不重复的全排列。 示例: 输入: [1,1,2]输出:[ [1,1,2], [1,2,1], [2,1,1]] 来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/permutations-ii 解答 ...
分类:
其他好文 时间:
2020-07-19 17:55:22
阅读次数:
60
406. 根据身高重建队列 贪心算法 思路参考:https://leetcode-cn.com/problems/queue-reconstruction-by-height/solution/gen-ju-shen-gao-zhong-jian-dui-lie-by-leetcode/ 第一次在排 ...
分类:
其他好文 时间:
2020-07-19 15:49:30
阅读次数:
63
Description You have k lists of sorted integers in ascending order. Find the smallest range that includes at least one number from each of the k lists ...
分类:
其他好文 时间:
2020-07-19 15:47:40
阅读次数:
73
给你一个二叉树,请你返回其按 层序遍历 得到的节点值。 (即逐层地,从左到右访问所有节点)。 示例: 二叉树:[3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回其层次遍历结果: [ [3], [9,20], [15,7] ] class Solution( ...
分类:
其他好文 时间:
2020-07-19 13:49:57
阅读次数:
77
给定一个二叉树,返回它的中序 遍历。 示例: 输入: [1,null,2,3] 1 \ 2 / 3 输出: [1,3,2] 进阶: 递归算法很简单,你可以通过迭代算法完成吗? ## 迭代 class Solution: def inorderTraversal(self, root: TreeNod ...
分类:
其他好文 时间:
2020-07-19 11:38:09
阅读次数:
55