Ad
  • Default User Avatar

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

  • Default User Avatar

    What complexity is about: how does the time processing grow against data growth.

    Think about how many times you have to parse data. If you parse it once, that's O(n). Twice should be O(2n) then, but we consider it as O(n) cause time processing still grows proportionally with data size. That's what we want to know. If you parse the whole data for each item, the processing time grows quadratically with data, that's O(n²). You can see n as number of items.

    So from here, you can deduce we also can have O(1): you don't parse data; O(n³): you parse whole data for each item for each item; O(n!): you parse whole remaining data for each item, O(log(n)): you parse half remaining data on each iteration; etc.

    You'll easily find documentations, graphs, tutorials, and so on (even hundreds pages book). Just look for it :)

    (If needed, a real pro will complete, precise, or correct…)