Ad
  • Custom User Avatar

    About the pattern:

    ["a", "b", "c"] ->
    ["a", "b", "c", "a", "a", "b", "b", "c", "c"] ->
    ["a", "b", "c", "a", "a", "b", "b", "c", "c", "a", "a", "a", "a", "b", "b", "b", "b", "c", "c", "c", "c"] -> ...
    

    Try using some math to predict the value on the passed position without building the whole list, that's the most I can tell without spoiling it.

  • Custom User Avatar

    Building the queue like that won't work (also, that's not a copy, it's another reference to the same array, mutating queue will mutate names because the array is the same). Shift and slice are in the worst case O(n) so those count like nested loops in time complexity. Also, building an array with so many items will exhaust memory at some point. You'll have to find a pattern instead so you can save cycles.

  • Custom User Avatar

    Could you post your current code using markdown formatting and marking your post as having spoiler content? Some array methods have loops under the hood, and that's why it times out.

  • Custom User Avatar

    Nested loops won't work, single loops works tho, use a more mathy approach.

  • Custom User Avatar

    (for JS): There's 10 fixed tests, 50 short string tests, and 10 long string tests (70 total), so you're probably timing out at long strings =/

    For reference, average solution takes about 9-10s.