Question: Without using library, How should I change the following code? Thanks void longestSubSeq_NoDup(const int* a, int n, int& start, int& len) { // Array a[]

Without using library, How should I change the following code? Thanks

void longestSubSeq_NoDup(const int* a, int n, int& start, int& len) {

// Array a[] is interpreted as a circular array.

// start = start index of the longest subsequence without duplicated value

// len = length of the longest subsequence without duplicated value // for this everything is same as part-1 but the difference is that here //we need to take a set so that we can check for duplicates. //and inner loop will run until it does not find duplicates. int longest_seq_size = 0; int index = 0; int i=0; for(int i=0;i s; int count=1; int j=i+1; s.insert(a[i]); while (j!=i && jlongest_seq_size) { index=i; longest_seq_size = count; } } start =index; len=longest_seq_size; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!