Ad
  • Custom User Avatar

    This solution is erroneous (based on both the nested for loops and final if/else statement on the ascCount and descCount.

    ascCount and descCount can be equal and also be in an unsorted array.

    Similarly, the if/else statement is therefore faulty based on the faulty counters.

    Revised solution works out all edge cases.

  • Custom User Avatar

    THIS reply is what helped me figure out what this question was asking, lolz.

    To further explain, these are some of the tests given:
    sumMul(n, m)
    sumMul(2,9) should return 20
    sumMul(3,13) should return 30

    We are looking for the sum of all the multiples of n up till the max value m.
    ex1) sumMul(2,9) should return 20
    multiples of 2 that are less than 9 = 2,4,6,8
    the summation of those numbers is 20

    ex2) sumMul(3,13) should return 30
    multiples of 3 that are less than 13 = 3,6,9,12
    the summation of those numbers is 30

    And so on.