Today I started doing coding kata. at first I try senior level of kata, buat ugh I can't.
Then I change the level to 'just learn to program' and it still takes time to me to finish the kata. I think I should practice more often and build discipline.
So Here is The kata I work on
Complete the method which accepts an array of integers, and returns one of the following:
"yes, ascending"- if the numbers in the array are sorted in an ascending order
"yes, descending"- if the numbers in the array are sorted in a descending order
You can assume the array will always be valid, and there will always be one correct answer.
I am still not fully satisfied with my solution because it require to loop the array 2 times. I believe there is an optimized solution that only require to loop the array once and have and O(n) complexity.