码迷,mamicode.com
首页 >  
搜索关键字:longest substring    ( 5540个结果
leetcode104 Maximum Depth of Binary Tree
1 """ 2 Given a binary tree, find its maximum depth. 3 The maximum depth is the number of nodes along the longest path from the root node down to the ...
分类:其他好文   时间:2020-02-02 23:16:12    阅读次数:93
动态规划 ---- 最长公共子序列(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
Go字符串
1. 字符串的声明是使用 package main import "fmt" func main() { /* Go中的字符串是一个字节的切片。 可以通过将其内容封装在“”中来创建字符串。Go中的字符串是Unicode兼容的,并且是UTF-8编码的。 字符串是一些字节的集合。 理解为一个字符的序列。 ...
分类:其他好文   时间:2020-02-01 10:31:14    阅读次数:86
[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
5540条   上一页 1 ... 36 37 38 39 40 ... 554 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!