How to discover the largest sequence between two vectors?

Asked

Viewed 70 times

0

I have two vectors, one with 10 elements and the other with 5 elements. I need to check how many of these elements are in sequence. For example:

I’m basically doing a program that draws 10 random numbers. I ask the user to enter with five numbers. I have to check how many numbers typed by the user correspond to the numbers within the array between the 10 numbers typed.

this program is like a lottery game, 10 numbers are drawn and the user enters with 5 numbers.

I want to know if the sequence of numbers typed by the user are inside the vector and if any of them are in the same typed sequence. ex. winnerNum = [23 56 67 06 43 22 59 24 90 66] Usernumb = [01 06 43 22 89]

numbers 06, 43, 22, are within the lottery vector and are in the same sequence. sequence = 3.

I’ve been trying for a few hours to find out what the biggest sequence is between them, but I can’t.

I can’t use any particular type of method, because I have to use only what was taught in class, which would be just while, for, if... those basic things.

  • From what I understand you are seeking maximum increasing subsequence. Take a look at this example: https://github.com/arturmbrasil/subsequencia_crescente_maxima/blob/master/subsequencia_crescente_maxima.py

  • 1

    put an example of the expected result, because the question is consphere... sequence necessarily means sequential numbers, for example "1,2,3"? or what is the range (2 in 2, etc)? pq using 2 arrays? is confused, explain better and show an example of the expected result

  • really was cofunso haha, I had typed this at dawn after about 10 hrs of coding, it was not I who was typing, it was my tiredness kk, I hope q improve understanding.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.