Ad
  • Custom User Avatar

    Test case 5 in Java is not about empty arrays. It's about nulls. Do you check for null in your code?

  • Default User Avatar

    Try to write down the till's contents after each transation.

    Take the series of customers with bills of [25, 50, 25, 100]:

    Step 1:
    Bills in till after the transation: 1x 25
    (customer paid his ticket and did not need change)

    Step 2:
    Bills in till: 1x 50
    (customer brought the 50 and received the 25 bill as remainder)

    Step 3:
    Bills in till: 1x 50, 1x 25
    (the customer paid his 25, needed no change, so the bill goes in the till)

    Step 4:
    Bills in till: none
    (customer came with a bill of 100, the clerk is able to use the 50+25 bills to hand him the change)

    Apply the same for [25, 25, 50, 100], till contents per step are:

    1. 25
    2. 25, 25
    3. 25, 50 (the 50 bill was received now, one 25 bill was given as rest)
    4. none (both bills used as rest)
  • Default User Avatar

    Hi @alex__c, granted, it may not be in the examples, but the Remarks portion of the directions do tell us that a or b might be [] (all languages except R, Shell). The word "or" instead of "and" that indicates that they could be different lengths. Best of luck!

  • Default User Avatar

    You can use the equality operator (==) with the null keyword. So, if (a == null) { do things differently }

  • Default User Avatar

    @Mariam:

    After careful consideration, I am fully sure I need to check for the abs() value when sorting, to handle negative numbers in the array. That is not the issue. Thank you for your contribution :)

    However, after re-re-checking my logic, I have found a pesky off-by-one error, so I will consider my issue as moot. It wasn't test case 8's fault.

    Instead, I have discovered that none of the examples even hint that the arrays might have different sizes, they are the same size in all examples. Another thing to consider....

    @Hobovsky:

    I have. It would have been more useful if you had directly quoted the parts you thought were relevant for me. In any case, thank you, I guess.

  • Default User Avatar

    omg, it looks like test case 5 HAS NO array b? Is it possible? What code I have to write to find out did main method passed both arrays or no? I do Java

  • Default User Avatar

    I have same problem. Cannot pass the test 5 that has two empty arrays. I do check empty arrays in the beggining. It works in IntellijiIdea but doesnt work here.
    if((a.length == 0) && (b.length == 0)){
    return true;
    }

  • Custom User Avatar
  • Default User Avatar

    hobovsky, I do it in Java. Why it is wrong?
    if((a.length == 0) && (b.length == 0)){
    return true;
    }

    I tryed && and & - nothing helps

  • Custom User Avatar

    ((a.length == 0) & (b.length == 0)) : It depends on language, but if this is exactly how you have it in code, then it's most probably wrong.

  • Default User Avatar

    no need to use abs. do not do it

  • Default User Avatar

    I passed 12 and failed in 1. Cannot pass test 5 with two empty arrays. But I do check length of both arrays and if BOTH of them are 0 I return TRUE ((a.length == 0) & (b.length == 0)) Am I right??

  • Default User Avatar

    Testcase 8 is strange. The last pair is definitely NOT a root and square pair, the root of 36481 is 191, not 195.

    I am printing arrays a and b in ascending order of their abs(values).

    Log:
    0 0
    1 1
    -14 196
    19 361
    144 20736
    161 25921
    195 36481 <-- ????

    expected: but was:

  • Default User Avatar

    11 squared is 121, do the math