Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This is a very good piece of code. Way more efficient and readable than mine. Congratulations! I will take the opportunity to learn some tricks from your code :)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Since you fail the random tests I strongly suppose that you modify the given input (for example you reverse it in place) and so the reference solution for the random tests doesn't work on the "good" array. Work on a copy of the given input. Cheers.

  • Custom User Avatar

    Question resolved...

  • Custom User Avatar

    Given almost all posts about getting timeout are marked as having spoilers because they have, and the same answers are repeated over and over, read this if that's your case:

    Your code's time complexity is O(n2) and that won't work here. You code's time complexity should be O(n) to pass. Try googling "Big O notation" (it's a long subject to explain it here properly), your code should work in linear time, so if your code use nested loops or a loop and a loop-alike method inside try another way.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    I'm having issues with the large array tests in Powershell. The test case and my code always arrive at the same final sum (value at index 0 in the result) but my results differ from the expected results by a small amount in every other value. I also end up with a shorter array by 2.

    As an example, the first 3 expected totals from a random test are 0, 5, 24 and my results are 0, 4, 14 yet we both end up with a final total of 8398.

    I output the array passed in and manually worked out the first few results. The results calculated manually match what my algorithm is calculating but do not match the expected results. Example from a random test:

    First few values: 16 16 18 14
    Expected results: 0 12 33 38
    My calculated results: 0 16 32 50

    I don't see how the expected results are getting calculated.

  • Custom User Avatar

    let's try this one:
    your code says (twice) if i[2] == "Y": etc...
    but... some cards would be at i[3], because the player's number has 2 digits
    so a card such as "A11Y" - you would consider it as red...
    hope it does it - close the question if it does :-)

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    You forgot the 0

  • Custom User Avatar

    Yes, I understand now. Thank you for the clarification!

  • Custom User Avatar

    It seems so, I guess to insert like that, you have to move all the other elements in the list internally. Read this

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Loading more items...