300 的最基础做法还是很好理解的。 对于nums[i],我们记录下它可以和前面的元素组成多长的最长子序列。 例如nums = [1, 2, 5, 4, x, ...], 我们就得到对应的记录数组 maxlen = [1, 2, 2, 3, y, ...]。 那么此时我们只需要在 1 ~ i-1 的 ...
转载
2021-09-20 00:49:00
64阅读
2评论
Parentheses Balance给定一串由()和[]组成的字符串。如果我们规定以下的字符串是合法的字符串:(1) 如果是空串,那么合法字符串。(2) 如果A、B是合法的,那么AB也是合法的字符串。(3) 如果A是合法的,那么(A)和[A]都是合法的字符串。换言之,如果字符串中离任一一个右括号(即')'或者’]')的最近的未配对左括号是配对的,且所有左右括号都已配对,那么它就...
原创
2021-07-27 19:48:19
72阅读
#include <bits/stdc++.h> using namespace std; stack<char> s; int num; /** 测试用例: 2 [({})] ()[]() */ char trans(char a) { if (a == ')') return '('; if (
原创
2021-11-26 13:37:14
11阅读
Parentheses Balance You are given a string consisting of parentheses () and []. Astring of this type is said to be correct: (a) if it is the empty string (b) if A and B are correct, AB is correct, (c) if A is correct, (A ) and [A ] is correct. Write...
转载
2013-08-18 22:11:00
22阅读
2评论
LeetCode每日一题2021.9.20 LeetCode673. 最长递增子序列的个数 思路 在最长上升子序列的转移时,维护一个 cnt 数组,表示 以 i 结尾的最长上升子序列个数 f[i] 表示以 i 结尾的最长上升子序列的长度 转移方程为 cnt[i] = (f[i] == f[j] + ...
转载
2021-09-20 20:39:00
28阅读
2评论
D. Bear and Two Paths time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bearland has n cit
转载
2020-01-16 14:03:00
72阅读
2评论
一个匹配左右括号的问题 /*UVa 673 Parentheses Balance*/#include#include#include#include#includeusing namespace std;char c[500];int n;int pd(char q,char e){ if(q...
转载
2016-04-28 22:32:00
56阅读
2评论
题目大意:判断输入的字符串是否为真。真的定义如下,1.空格;2.AB(AB都为真);3.[A],(A)解题思路:从字符串内部判断,用栈模拟,空
原创
2021-12-01 16:18:26
88阅读
题目大意:给出一系列的字符串,问括号的写法是否正确解题思路:
原创
2023-04-07 10:43:01
40阅读
DescriptionYou are given a string consisting of parentheses()and[]. A string of this type is said to becorrect:(a)if it is the empty string(b)if A and B are correct, AB is correct,(c)if A is correct, (A )and [A ]is correct.Write a program that takes a sequence of strings of this type and check their
转载
2013-07-04 19:38:00
68阅读
2评论
//UVa673 - Parentheses Balance//已AC#include<iostream>#include<string>#include<stack>using namespace std;int main(){ int T; cin>>T; getchar(); //cin.get(); 读取整数后面的第一个换行...
原创
2023-02-08 10:59:52
106阅读
悟空的难题时间限制:1000 ms | 内存限制:65535 KB难度:2描述自从悟空当高排成一队。猴子们是如此
原创
2022-07-29 13:51:23
44阅读
#include
using namespace std;
const int maxn = 1e5+6;
int vis[100];
int main()
{
int n;
scanf("%d",&n);
for (int i = 1;i<=n;i++)
{
int temp;
scanf("%d",&temp);
vis[temp]=1;
}
原创
2023-06-09 18:28:39
15阅读
题意:看括号是否匹配
解题思路:一直想用递归来做,发现做不出 后来才想到消去当今可以消去的() 与 【】 的括号 循环找就行了
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
char str[1000];
int main()
{
int t ;
scanf("%d"
转载
2013-05-15 20:17:00
54阅读
2评论
题解:把第一个括号放到栈里,然后看后面的一个括号是否和他匹配,如果匹配就把栈里的括号取出,否则就把当前的括号也放进栈里
原创
2023-06-29 00:00:41
16阅读
RouterA相关配置】1. 创建(进入)E0.1子接口[RouterA]inter Ethernet 0.12. 在E0.1子接口里封装vlan10[RouterA-Ethernet0.1]vlan-type dot1q vid 103. 在E0.
转载
精选
2009-01-09 14:40:49
457阅读
交换机VLAN配置1 功能需求及组网说明VLAN 配置『配置环境参数』SwitchA端口E0/1属于VLAN2,E0/2属于VLAN3『组网需求』把交换机端口E0/1加入到VLAN2 ,E0/2加入到VLAN32 数据配置步骤『VLAN配置流程』1
转载
2009-01-09 14:42:37
324阅读
华为交换机配置实例LANSWITCH配置注意事项序号 注意项目 记录1 登录交换机时请注意在超级终端串口配置属性流控选择“无” 2 启动时按”ctrl+B”可以进入到boot menu模式 3 当交换机提示”Please Press ENTER”,敲完回车后请等待一下,设备需要一定的时间才能进入到命令行界面(具体的时间视产品而定)
转载
精选
2009-01-09 14:43:54
519阅读
交换机VLAN配置1 功能需求及组网说明VLAN 配置『配置环境参数』SwitchA端口E0/1属于VLAN2,E0/2属于VLAN3『组网需求』把交换机端口E0/1加入到VLAN2 ,E0/2加入到VLAN32 数据配置步骤『VLAN配置流程』1
转载
2010-01-18 01:07:51
304阅读
【RouterA相关配置】1. 创建(进入)E0.1子接口[RouterA]inter Ethernet 0.12. 在E0.1子接口里封装vlan10[RouterA-Ethernet0.1]vlan-type dot1q vid 103. 在E0
转载
2010-01-18 01:09:15
341阅读