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.
(OP's language was Java) added fixed tests with duplicate elements
Your code does almost the same thing, but manually checks the difference sign and changes it to positive by itself, which adds extra if statements. They can slow things down a bit, especially if the code is executed many times. Math.abs() will work faster. The difference is minimal.