tony

Cool Learning Tool for Programming

Category: /Programming/
(1280 views)
Like
0


https://www.algoexpert.io

/questions/Validate Subsequence



import java.util.*;

class Program {
public static boolean isValidSubsequence(List array, List sequence) {
// Write your code here.

int currentPosition = 0;
for (Integer element : sequence) {
if(array.indexOf(element) < currentPosition){
return false;
}
else{
currentPosition = array.indexOf(element);
array = array.subList(currentPosition+1, array.size());
currentPosition = 0;
}
}
return true;
}
}

Favorite Favorite  Comment Comment  Share Share

Close

Copy Link and Share



Report an item by sharing it with support.
© individual authors and creators. Create, Share and Profit at etastic.com.

Add a Comment

Enter your comment and submit

© Copyright etastic and individual authors. All Rights Reserved.

Edit Comment

Edit your comment and submit

© Copyright etastic and individual authors. All Rights Reserved.