
Letcode
cy320h
不知道你在想什么
展开
-
Letcode 删除一次得到子数组的最大和
dp[i]求子数组的最大和,使用地推公式ans=max(ans,left[i-1]+right[i+1])left[i]:标识从左到右i下标结尾的最大子数组和right[i]:标识从右到左i下标结尾的最大子数和int maxsum(vector<int>&arr){ int len = arr.size(); int ans = 0; vector<i...原创 2019-12-13 15:25:27 · 186 阅读 · 0 评论 -
子矩阵的最大累加和
一、题目要求给定一个矩阵matrix,其中的值有正有负,有0,返回子矩阵的最大累加和,例如,矩阵matrix为:-90 48 7864 -40 64-81 07 66其中,最大累加和的子矩阵为:48 78-40 64-7 66所以返回累加和209二、解题思路将矩阵matrix[N][N]的每一列的N个元素累加成一个累加数组,然后求出这个数组的最大累加和,...原创 2018-06-04 09:35:52 · 214 阅读 · 0 评论 -
sort list
Sort a linked list in O(n log n) time using constant space complexity.归并排序的解法题目要求:对链表进行排序 解题思路:归并排序,再Merge 归并排序的基本思想是:找到链表的中间节点,然后递归对前半部分和后半部分分别进行归并排序,最后对两个排好序的链表进行Merge class Solution { p...原创 2018-06-13 20:50:29 · 321 阅读 · 0 评论 -
Pascal's Triangle [118]
【题目】Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]就是...原创 2018-07-01 18:35:47 · 227 阅读 · 0 评论 -
Binary Tree Level Order Traversal II
Binary Tree Level Order Traversal II 题目描述 Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root).For exa...原创 2018-06-28 20:20:38 · 174 阅读 · 0 评论 -
LeetCode15:3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c) must b...原创 2018-07-29 15:14:01 · 210 阅读 · 0 评论