• Venator@lemmy.nz
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    4 months ago

    Why would you want a specific time complexity? Wouldn’t it be better if it’s faster? /s

    • JaddedFauceet@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      4 months ago

      Likely they want a lower time complexity.

      for example a question can be trivially solved in O(n^2). but there is no know < O(n) solution, so they ask for O(n)

      • lad@programming.dev
        link
        fedilink
        English
        arrow-up
        1
        ·
        4 months ago

        That’s a huge leap from O(n²) to O(n), in this example it would likely good to at least specify that it should be strictly less than best known solution (not sure if there are such cases on leet code, I thought they only restrict you to what is known to be solvable)