Java 1D Array (Part 2)

  • + 1 comment

    Can I know the overall time complexity for your solution to this problem?

    • + 0 comments

      Good question. Let n be # of elements in our array. The time complexity is O(n) since we visit each element in the array a maximum of 1 times. (Technically, we do sometimes revisit an element, but since we already marked it as visited, we immediatelly return, so this only adds a constant factor to our runtime)

      HackerRank solutions.