The largest sequential subsystem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The largest sequential subsystem

the sub sequential in array

20th May 2017, 8:44 AM
Ahmad Dregat
Ahmad Dregat - avatar
1 Answer
0
You mean the largest sequential subsequence? In which case, go through the array, keep track of the last digit you saw, keep track of the longest sequence you've seen, and the length of the current sequence. At the end, you can print out the longest sequence. Alternatively if you need to print out the longest sequence, we can keep track of the start and stop indices of the longest sequence and the current sequence.
11th Jun 2017, 2:44 AM
Jason Runkle
Jason Runkle - avatar