The Wayback Machine - https://web.archive.org/web/20201103184339/https://github.com/TheAlgorithms/Java/pull/1424
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

Create Range.java #1424

Open
wants to merge 3 commits into
base: master
from
Open

Create Range.java #1424

wants to merge 3 commits into from

Conversation

@gijsh21
Copy link
Contributor

@gijsh21 gijsh21 commented Aug 19, 2020

For finding the range of an array of numbers

gijsh21 added 2 commits Aug 19, 2020
For finding the range of an array of numbers
For arrays of length one, I was returning the number in the array. Of course, 0 should be returned instead. Fixed.
@drabbit75
Copy link
Member

@drabbit75 drabbit75 commented Aug 20, 2020

why do you not use template class,

@gijsh21
Copy link
Contributor Author

@gijsh21 gijsh21 commented Aug 20, 2020

As in a generic class? I don't think they work for primitives, at least I can't seem to get them to work.

Substantial performance improvement by not sorting the array and subtracting the first element from the last, but instead directly finding the minimum and maximum values in a single iteration.
@drabbit75
Copy link
Member

@drabbit75 drabbit75 commented Aug 21, 2020

en, I just make a mistake

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

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.