码迷,mamicode.com
首页 >  
搜索关键字:longest consecutive    ( 3017个结果
leeetcode1171 Remove Zero Sum Consecutive Nodes from Linked List
1 """ 2 Given the head of a linked list, we repeatedly delete consecutive sequences of nodes that sum to 0 until there are no such sequences. 3 4 Afte ...
分类:其他好文   时间:2020-02-01 23:18:44    阅读次数:83
动态规划 ---- 最长公共子序列(Longest Common Subsequence, LCS)
分析: 完整代码: // 最长公共子序列 #include <stdio.h> #include <algorithm> using namespace std; const int N = 100; char A[N], B[N]; int dp[N][N]; int main() { freop ...
分类:其他好文   时间:2020-02-01 14:15:10    阅读次数:61
[LC] 543. Diameter of Binary Tree
Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longestpath betwee ...
分类:其他好文   时间:2020-02-01 11:02:57    阅读次数:105
[leetcode]Longest Substring with At Most K Distinct Characters
Python3,双指针,注意K为0的情况。 class Solution: def lengthOfLongestSubstringKDistinct(self, s: str, k: int) -> int: if k == 0: return 0 charMap = {} result = 0 ...
分类:其他好文   时间:2020-01-31 15:49:02    阅读次数:57
[leetcode]Longest Univalue Path
要注意边和节点数是不一样的 # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None cl ...
分类:其他好文   时间:2020-01-31 10:21:14    阅读次数:76
Max Consecutive Ones III
Given an array A of 0s and 1s, we may change up to K values from 0 to 1. Return the length of the longest (contiguous) subarray that contains only 1s. ...
分类:其他好文   时间:2020-01-31 00:59:06    阅读次数:67
leetcode动态规划综述图
转自 https://leetcode-cn.com/problems/longest-palindromic-substring/solution/zhong-xin-kuo-san-dong-tai-gui-hua-by-liweiwei1419/ ...
分类:其他好文   时间:2020-01-30 20:58:05    阅读次数:71
P1807 最长路
题目链接 题目描述 设G为有n个顶点的有向无环图,G中各顶点的编号为1到n,且当为G中的一条边时有i < j。设w(i,j)为边的长度,请设计算法,计算图G中<1,n>间的最长路径。 输入格式 输入文件longest.in的第一行有两个整数n和m,表示有n个顶点和m条边,接下来m行中每行输入3个整数 ...
分类:其他好文   时间:2020-01-30 20:50:28    阅读次数:88
Leetcode总结帖【1-10】
1. Two sum 因为只有一个solution(pair),所以一旦发现解返回即可。使用unordered_map或者unordered_set存当前数字,找complement. 2. Add two number 双指针,使用dummy作为返回链表。 3. Longest substring ...
分类:其他好文   时间:2020-01-30 09:17:40    阅读次数:68
leedCode练题——14. Longest Common Prefix
1、题目 14. Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, re ...
分类:其他好文   时间:2020-01-29 17:50:57    阅读次数:65
3017条   上一页 1 ... 16 17 18 19 20 ... 302 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!