Skip to content

[Enhancement] ContainsDuplicate complexity #1

Description

@harshithasudhakar

In ContainsDuplicate.java, the current solution has a time complexity of O(n^2), where n is the number of elements in the array. This can become very slow for larger arrays.

We can still do it solely using arrays, by first sorting the array. Then, iterating through the sorted array and checks if adjacent elements are equal. This can lead to a time complexity of O(n log n).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions