Count The Repetitions


  • 1
    A

    Click here to see the full article post


  • 0
    A

    Does this line have problem? (countr[i] - countr[k]) * (n1 - 1 - k) / (i - k)
    Shouldn't it be (countr[i] - countr[k]) * ((n1 - 1 - k) / (i - k)).
    For example if (countr[i] - countr[k]) = 3, (n1 - 1 - k) = 19, (i - k) = 5.
    Than use the first line, it is (3 * 19) / 5 = 11;
    But actually it should be 9, which is 3 * (19 / 5).


  • 0
    T

    Yes, I think you're right. For Python, that line should be changed to (countr[i] - countr[k]) * ((n1 - 1 - k) / (i - k)) to pass the 41st test case.


  • 0

    Input:
    "aaa"
    20
    "aaaaa"
    1
    Output:
    14
    Expected:
    12


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.