Its not bad.
Just remember to make your code easy to understand to others.
Also try not to repeat yourself. You are calculating 3 times the where the half is.
Instead you can make a specific variable for it at the beginning solving both of your problems.
I think your solution is way less efective, and in this top rated solution is problem with creating String s (it's redundant) we should just return new string from substring and that is it. Clear effictient and without redundancy :).
I just looked into it and your are right -0 is a thing however unless in string form it has no effect as 0 == -0. As well, this is only the case with floats and the desired return type is an integer. Because in java twos complete is used for integers -0 can't be created for integers.
Its not bad.
Just remember to make your code easy to understand to others.
Also try not to repeat yourself. You are calculating 3 times the where the half is.
Instead you can make a specific variable for it at the beginning solving both of your problems.
Someone can give me feedback about my solution?
This comment is hidden because it contains spoiler information about the solution
I think your solution is way less efective, and in this top rated solution is problem with creating String s (it's redundant) we should just return new string from substring and that is it. Clear effictient and without redundancy :).
First comment I've left on this website; nice job
It's bad practice! Because every use of the substring method creates a new string. Hence we pollute the string pool. See mine....
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
very smart
dumb af
This comment is hidden because it contains spoiler information about the solution
I just looked into it and your are right -0 is a thing however unless in string form it has no effect as 0 == -0. As well, this is only the case with floats and the desired return type is an integer. Because in java twos complete is used for integers -0 can't be created for integers.
No, no point.
Is there any point in this because 0 * (-1) == 0?