Longest sequence

  • 10
  • Locked
If numbers repeat themselves, does that mean that somebody wants it that way? At present, we need repeated numbers to practice completing tasks with lists. Let's create a list of numbers and add 10 numbers from the keyboard. Our task is to display the length of the longest sequence of repeating numbers in a list.
You can't complete this task, because you're not signed in.
Comments(21)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
frimpong kwameLevel 8 , Accra
Wednesday, 22:29
The longest sequence task was really hard for me.
Lucas HoageLevel 14 , Savannah
2 June, 02:53
Very high difficulty.
IvanPLevel 13 , Barcelona
5 May, 15:40
I recommend you to validate this before submiting
// 2, 4, 4, 4, 8, 8, 4, 12, 12, 14           -> 3
// 89 12 12 98 111 42 98 98 98 71    -> 3
// 1, 1, 1, 1, 1, 1, 1, 1, 1, 1                 -> 10
Dave AndreaLevel 25
10 April, 01:33
34 validations later... Finally got it.
JeffLevel 22 , Spartanburg
11 March, 23:37
Always create tests for base cases. In The Longest Sequence those cases are a) all numbers are different, and b) all numbers are the same. Then develop a test for c) a sequence of repeating numbers.
IO.ErrorLevel 24 , Bremen
25 January, 22:05
Check result for 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 as well - maybe this helps someone
JeffLevel 22 , Spartanburg
11 March, 23:30
Good advice.
Devonte ALevel 14 , Rubery
11 June, 15:39
What should the value be if the numbers in that order?
nullLevel 22 , Orlando
22 January, 20:54
Out of bound issue took me 19 trials to get it correct :(
Liliane TopLevel 17 , Amsterdam
14 February, 21:10
Well at least you got it. I'm still struggling for more than a day and still clueless. Cheers.
nullLevel 22 , Orlando
19 February, 21:43
you can do it. Draw out a picture. Ask a question if you need help. I bet other people will help you get thru it.
PritinaikLevel 8 , Mumbai
30 August 2019, 17:30
Whats wrong with my code? the last requirement is not met whereas i am getting the correct answer.
VrhLevel 9 , Zagreb
13 July 2019, 16:59
Loved this assignment. It was cool to get an error message about numbers bigger than 128 and than figuring it out.
Muhammad VahhaajLevel 19 , Rawalpindi
13 July 2019, 14:51
It is strange that if(127==127) evaluates to true but (128==128) evaluates to false. Maybe it has to do something with the reference type. Hint 1: Use 2 counters, first counter will be assigned the longest occurrence and the second counter will be used to get the occurrences for each set. Hint 2: Use equals method of the Integer class do not use the comparing operator since the Reference objects are dealt(so it will produce weird result in case of numbers greater than 127).
Radostin IvanovLevel 8 , Ruse
28 September 2019, 23:02
Helpful. Thank you :)