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.
It is considered bad coding practices to mutate an array or object in-place instead of creating a copy of it for further usage. One thing is that the original input is changed and if you want to debug your code based on the given input, it is not possible. The other thing is it will result in Undefined behaviour (UB) especially when the test setups, assertions and invoke callers are related to the input of your function, in which modifying it will cause other programs to read the incorrect initial or intermediate value.
From a theoretical standpoint, looping once for the minimum and once for the maximum is equivalent to looping once and checking for maximum and minimum at the same time (time complexity).
While this version looks nicer, you're performing a comparison of 2 values, 2 times, for each entry in the array. Additionally, you're always rewriting the value in the local variables.
Perhaps it's better to simplify to 2 ifs, and only write when relevant.
indeed you can
It was a homework assignment for an algorithms class I did a while back. I translated my answer from psudocode to java.