hdoj 5818 5821,应聘高级Android工程师历程感言

for(i=0;i<n;i++){

vis[a[i]][0]++;

cnt[i]=vis[a[i]][vis[a[i]][0]];

}

for(i=0;i<m;i++){

scanf(“%d %d”,&x,&y);

sort(cnt+x-1,cnt+y);

}

int flag=1;

for(i=0;i<n;i++){

if(cnt[i]!=i) flag=0;

}

if(flag) printf(“Yes\n”);

else printf(“No\n”);

}

return 0;

}

Problem Description

A stack is a data structure in which all insertions and deletions of entries are made at one end, called the “top” of the stack. The last entry which is inserted is the first one that will be removed. In another word, the operations perform in a Last-In-First-Out (LIFO) manner.

A mergeable stack is a stack with “merge” operation. There are three kinds of operation as follows:

- push A x: insert x into stack A

- pop A: remove the top element of stack A

- merge A B: merge stack A and B

After an operation “merge A B”, stack A will obtain all elements that A and B contained before, and B will become empty. The elements in the new stack are rearranged according to the time when they were pushed, just like repeating their “push” operations in one stack. See the sample input/output for further explanation.

Given two mergeable stacks A and B, implement operations mentioned above.

Input

There are multiple test cases. For each case, the first line contains an integer  N(0<N≤105) , indicating the number of operations. The next N lines, each contain an instruction “push”, “pop” or “merge”. The elements of stacks are 32-bit integers. Both A and B are empty initially, and it is guaranteed that “pop” operation would not be performed to an empty stack. N = 0 indicates the end of input.

Output

For each case, print a line “Case #t:”, where t is the case number (starting from 1). For each “pop” operation, output the element that is popped, in a single line.

Sample Input

4

push A 1

push A 2

pop A

pop A

9

push A 0

push A 1

push B 3

pop A

push A 2

merge A B

pop A

pop A

pop A

9

push A 0

push A 1

push B 3

pop A

push A 2

merge B A

pop B

pop B

pop B

0

Sample Output

Case #1:

2

1

Case #2:

1

2

3

0

Case #3:

1

2

3

0

F题题意简单,给一个只有(和)的字符串,是否能更换任意两个位置的括号使这个字符串的所有括号都能匹配。

用栈来做,数组来存没有匹配到的括号,先匹配完所有可以匹配的括号,剩下的处理。

不过要注意:‘()‘  这种情况不行,因为必须要更换一次。

还有‘))((’是可以通过更换匹配的到的,特判写一下就能过了。

#include

#include

#include

#include

#include

using namespace std;

#define N 100010

stacka;

char s[N],k[N];

int main()

{

int i,j,n,cnt,res,T,l,r;

char x;

scanf(“%d”,&T);

while(T–)

{

scanf(“%d”,&n);

l=0,r=0;

for(i=1;i<=n;i++){

cin>>x;

k[i]=x;

if(x==‘)’) r++;

else l++;

a.push(x);

由于篇幅原因,这份面试宝典已经被整理成了PDF文档,有需要Android面试宝典全套完整文档的麻烦点赞+点击GitHub即可获取资料免费领取方式!

本文在开源项目:GitHub中已收录,里面包含不同方向的自学编程路线、面试题集合/面经、及系列技术文章等,资源持续更新中…

自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级安卓工程师,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年最新Android移动开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
img
img
img
img

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
img

外链图片转存中…(img-Q9b9mCSJ-1710969009128)]
[外链图片转存中…(img-4eSbFprd-1710969009128)]
[外链图片转存中…(img-aDmkALay-1710969009129)]
[外链图片转存中…(img-mtoo1yF1-1710969009130)]

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注Android)
[外链图片转存中…(img-68EBDdFV-1710969009130)]

  • 12
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值