Ad
  • Default User Avatar

    Because in the second for loop we dont want to compare the same letter to itself.
    Also, there is no need to compare the second letter to the first, third letter to the first and second, and so on, if youve already compared them before ever reaching to that particular letter.

    i.e
    [a, b, c, d , e ,a]
    starting from a, you compare it to everything but itself.
    when youre at b, you dont need to compare it to a since you did that already. This continues for each letter. Makes sense?