Ad
  • Custom User Avatar

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

  • Custom User Avatar

    Oh, you're right. I wasn't seeing the correct logs.

    Sorry.

  • Custom User Avatar

    You would be correct, however I am saying that when I run your code, I don't see this behavior. Are you sure you aren't misreading the logs?

    Here is what I see after running your code a few times:

    arr[]:1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 
    arr_sz: 14
    mix_arr[]:6, 13, 8, 4, 12, 1, 5, 11, 3, 10, 2, 9, 7, 14, 
    mix_sz: 13
    return base: 0
    Expected: 14
    Received: 0
    
    arr[]:1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 
    arr_sz: 10
    mix_arr[]:9, 4, 7, 2, 3, 8, 6, 5, 1, 10, 
    mix_sz: 9
    return base: 0
    Expected: 10
    Received: 0
    
    arr[]:1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 
    arr_sz: 29
    mix_arr[]:21, 7, 8, 23, 17, 26, 1, 2, 6, 5, 14, 3, 12, 22, 18, 9, 25, 16, 24, 27, 11, 15, 10, 19, 4, 28, 13, 20, 29, 
    mix_sz: 28
    return base: 0
    Expected: 29
    Received: 0
    

    You may be mistaking the log above the "returned... received..." part as the log for the failed test, but it's not. Note that when you print the values of arr, your loop prints one value too many (you're printing a value in memory right after the array), which can lead to confusing looking logs.

  • Custom User Avatar

    Sorry. Maybe I didn't understand.
    If arr_sz is 19, the arr object will stop at 19, right? So, the expected output can't be 21, because the number is greater than the arr_sz

    Is it correct?

  • Custom User Avatar

    I could not replicate this with your current code, but there is no mistake. Your current code doesn't check the last number of arr.

  • Custom User Avatar

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