You are auto-boxing the results of your function call, only to un-box them later. If everything else is using double
(a primitive), there is no reason to declare the local variables in solution()
as Double
(an object). This doesn't effect the big-O of your solution, but it is extra operations for the JVM to execute.
Give your class and public method better names. If you actually needed this in production code, there would be no way to know what this code did. The names tell you nothing and there is no documentation.
There is a max()
, but it works on Collection
s, not arrays. However, writing your own max method is not that hard, so it is up to you if you want to replace it.
Note: Until seeing you question, I didn't know that Double.MIN_VALUE
and Integer.MIN_VALUE
do not represent the same concept for the respective type. This isn't your fault, but it is unintuitive. Explination Explination
You are auto-boxing the results of your function call, only to un-box them later. If everything else is using double
(a primitive), there is no reason to declare the local variables in solution()
as Double
(an object). This doesn't effect the big-O of your solution, but it is extra operations for the JVM to execute.
Give your class and public method better names. If you actually needed this in production code, there would be no way to know what this code did. The names tell you nothing and there is no documentation.
There is a max()
, but it works on Collection
s, not arrays. However, writing your own max method is not that hard, so it is up to you if you want to replace it.
Note: Until seeing you question, I didn't know that Double.MIN_VALUE
and Integer.MIN_VALUE
do not represent the same concept for the respective type. This isn't your fault, but it is unintuitive. Explination
You are auto-boxing the results of your function call, only to un-box them later. If everything else is using double
(a primitive), there is no reason to declare the local variables in solution()
as Double
(an object). This doesn't effect the big-O of your solution, but it is extra operations for the JVM to execute.
Give your class and public method better names. If you actually needed this in production code, there would be no way to know what this code did. The names tell you nothing and there is no documentation.
There is a max()
, but it works on Collection
s, not arrays. However, writing your own max method is not that hard, so it is up to you if you want to replace it.
Note: Until seeing you question, I didn't know that Double.MIN_VALUE
and Integer.MIN_VALUE
do not represent the same concept for the respective type. This isn't your fault, but it is unintuitive. Explination
You are auto-boxing the results of your function call, only to un-box them later. If everything else is using double
(a primitive), there is no reason to declare the local variables in solution()
as Double
(an object). This doesn't effect the big-O of your solution, but it is extra operations for the JVM to execute.
Give your class and public method better names. If you actually needed this in production code, there would be no way to know what this code did. The names tell you nothing and there is no documentation.
There is a max()
, but it works on Collection
s, not arrays. However, writing your own max method is not that hard, so it is up to you if you want to replace it.
Note: Until seeing you question, I didn't know that Double.MIN_VALUE
and Integer.MIN_VALUE
do not represent the same concept for the respective type. This isn't your fault, but it is unintuitive. Explination