Thanks for your help. But is this logic correct, i.e., will it work for all small test cases?

Active In

Competitive Programming

Algorithms and Data Structures

Featured Contributions

comment in this discussion

Thanks for your help. But is this logic correct, i.e., will it work for all small test cases?

Read more… (18 words)

comment in this discussion

Can anyone tell me what I am doing wrong. I am using dsu for finding if there is cycle or not.

#include<bits/stdc++.h>using namespace std;int a[100010],b[100010];int find(int x){if(a[x]<0)return x;a[x]=find(a[x]);return a[x];}void uni(int x,int y){if(a[x]==a[y]){a[x]--;a[y]=x;}

Read more… (21 words)

comment in this discussion

- I am finding LIS from left to right.
- Then I am making an array of remaining values and then finding longest decreasing sequence in it.
- Calculating LIS+LDS.
- I am doing point 2 for every LIS (if there are more than 1) and then taking maximum value as my answer. Is my logic correct. I am getting wrong answer. Can anyone give me some counter example?

Read more… (65 words)

comment in this discussion

Did your code get accepted as according to me it should fail in this test case:

8abcdecba

Correct me if I am wrong.

Read more… (22 words)