7 kyu

Max span

Description
Loading description...
Algorithms
Arrays
  • Please sign in or sign up to leave a comment.
  • trashy_incel Avatar

    typo in description:

    between the the same --> between the same

  • laurelis24 Avatar

    There's no way this is 7kyu.

  • ejini战神 Avatar
    • Node 12 should be enabled (Refer this and this for more info)
  • RealKenshiro Avatar

    Nice Kata but description is cryptic, spent too much time on understanding the task:

    For arr = [1, 4, 2, 1, 4, 1, 4, 9, 7, 7, 7]

    Non unique values are 1, 4 and 7

    1. Value 1 generate sub array [1, 4, 2, 1, 4, 1] -> length = 6
    2. Value 4 : [4, 2, 1, 4, 1, 4] -> length = 6
    3. Value 7 : [7, 7, 7] -> length = 3

    So maximum span is 6

    For arr = [1, 4, 6, 1, 4, 4, 4, 8 ,6, 2, 3]

    Non unique values are 1, 4 and 6

    1. Value 1 : [1, 4, 6, 1] -> length = 4
    2. Value 4 : [4, 6, 1, 4, 4, 4] -> length = 6
    3. Value 6 : [6, 1, 4, 4, 4, 8 ,6] -> length = 7

    So maximum span is 7

  • dagolinuxoid Avatar

    [1, 2, 1, 1, 3, 4, 5, 6, 7, 8, 8] → 4 // span is (1, 2, 1, 1)

    Span is a number of elements between same elements: Same element in this array are 1 and 8 only, so span(amount of numbers) between first 1 (index 0) and second 1 is == 1. betwen first and last - the span is == 2. Or span between same elements (1,1) and (8,8) is 5. You get (1,2,1,1) and 4 as a result I do NOT get it. Can you explain your kata further? PS.Next day — Finally I got it :) Maybe it's a good idea to make the description crystal clear.

  • dinglemouse Avatar

    For me all the random tests say "Expected 1"

     Random Tests
     Log
    [ 5, 7, 8, 7, 5, 7, 2, 3, 2, 2, 6, 4, 8, 4, 2 ]
     Test №1
    It should work for random tests too - Expected: 1, instead got: 11