Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
An important skill in software engineering is reading the requirements thoroughly.
It doesn't filter negative values; if we have -10 and -5 as inputs, this function would return 49.
I prefer to filter out by invalid values n,m. Then there is no unneeded multiplication happening
No, but return value is integer anyway, so there is no possible way to return correct value using integer. We can return 0 in this case, because input data will be kind of incorrect, but I don't think it's a good way to solve the task.
Description says: "Input will always be a non-negative integer.", so we can omit handling this case
What about negative values? For example n = -5, m = -4. I think it should return 0. Your solution will give 19.
Will this solution work if
(n * m - 1) > Integer.MAX_VALUE
?Nice solutions!!!
Why compute breaks, if you can simply check n & m ?
haha nice one
This is really clever, I never thought of using the max method to filter out the negative values.
The test for the Java fails passing solutions because the test is static
but it's handy for assignment
the return statement isn't required.