码迷,mamicode.com
首页 >  
搜索关键字:two pointers    ( 12138个结果
LeetCode617合并二叉树
题目链接 https://leetcode-cn.com/problems/merge-two-binary-trees/ 题解 递归解法 解法见代码注释 // Problem: LeetCode 617 // URL: https://leetcode-cn.com/problems/merge- ...
分类:其他好文   时间:2020-07-26 01:03:49    阅读次数:54
Codeforces #659 A. Common Prefixes
##题面 he length of the longest common prefix of two strings s=s1s2…sn and t=t1t2…tm is defined as the maximum integer k (0≤k≤min(n,m)) such that s1s2…s ...
分类:其他好文   时间:2020-07-26 00:15:56    阅读次数:106
Dreamoon-Two matchings(DP)
题目大意: 给出个点,n为偶数,询问两个完全没有交集的匹配q和p。 一方面使得n个点两两互相匹配,一方面使得匹配的权值和最小 分析: 因为n是偶数,所以可以考虑将n个数分配到不同的长度为偶数的环中,对于排列q和排列p,只需要在偶环中交换一下位置就好。 但这个偶环的长度必须要大于2,因为如果长度为2, ...
分类:其他好文   时间:2020-07-24 21:58:55    阅读次数:72
dict
>>>dict() # 创建空字典 {} >>> dict(a='a', b='b', t='t') # 传入关键字 {'a': 'a', 'b': 'b', 't': 't'} >>> dict(zip(['one', 'two', 'three'], [1, 2, 3])) # 映射函数方式来构 ...
分类:其他好文   时间:2020-07-24 19:10:00    阅读次数:67
pytest 生成测试报告
pip安装 pip install pytest-html 编写脚本 import pytest class TestClass(object): def test_one(self): x = "this" assert 'h' in x def test_two(self): x = "hell ...
分类:其他好文   时间:2020-07-23 16:50:29    阅读次数:121
检查字符串是否包含另一串字符串(c++)
在c++中检查字符串是否包含另一串字符串,这个本来是我做过的一个算法题,不过最近刚好有个需求让我想到了这个题,就在此记录一下! 使用std::string::findfunction string str ("There are two needles in this haystack."); st ...
分类:编程语言   时间:2020-07-22 02:02:45    阅读次数:79
CF1366E Two Arrays(思维+数学)
对于这道题,可以想想对于每个b[i],a[i]中可选的位置的区间在哪,这样只要找到区间,就能知道当前可以选那几个位置断开 b[1]的开头肯定是1号位,而我们发现如果对后缀求一下后缀的最小值,这样就天然满足题目条件,我们用一个map存一下答案,就能知道b[i]是最小值的区间是哪些 因为b是单调递增的数 ...
分类:其他好文   时间:2020-07-22 02:00:03    阅读次数:62
gradle 中项目的多目录组织形式
在gradle中,如果多个子项目使用目录进行分组,可以使用如下方法 // include two projects, 'foo' and 'foo:bar' // directories are inferred by replacing ':' with '/' include 'foo:bar' ...
分类:其他好文   时间:2020-07-21 22:45:12    阅读次数:108
Codeforces 189 A. Cut Ribbon(DP 恰装满的完全背包问题)
题目链接 Polycarpus has a ribbon, its length is n. He wants to cut the ribbon in a way that fulfils the following two conditions: After the cutting each r ...
分类:其他好文   时间:2020-07-21 21:35:20    阅读次数:72
[POJ1354D]Multiset(权值线段树)
【原题】 Note that the memory limit is unusual. You are given a multiset consisting of nn integers. You have to process queries of two types: add integer  ...
分类:其他好文   时间:2020-07-21 21:33:29    阅读次数:83
12138条   上一页 1 ... 9 10 11 12 13 ... 1214 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!