-
Notifications
You must be signed in to change notification settings - Fork 57
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
Added-cpp-solution #45
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this passes the test. but why this works? seems the complexity is n * n?
Yes it runs at n^2. I uploaded it as it will be easy to understand for beginners. I can also add the solution that has linear time complexity. |
I updated the code. You may check. Thanks |
this works as well -- except that the run time complexity is bigger than "Your algorithm should run in O(n) time and uses constant extra space." this implies modifications of the input array IMO. without this constraint, this problem would be easy |
Ok.. I accept. Now you can check. I've updated the solution that runs in linear time and with constant space. |
it is actually still not o n since u r using sort |
No description provided.