Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delete_nth.py Time Complexity #648

Open
basanneh opened this issue Apr 9, 2020 · 1 comment
Open

delete_nth.py Time Complexity #648

basanneh opened this issue Apr 9, 2020 · 1 comment

Comments

@basanneh
Copy link

basanneh commented Apr 9, 2020

Is the time complexity of the naive method also linear time instead of quadratic ?

@ericklarac
Copy link
Collaborator

Suppose the input array is a sequence from 1 to n without duplicates, and the value for n is 2.

Since each value appears only once, when the for is processing the last value of the input the ans.count(num) will compare n-1 times, this yields the n^2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants