I'm going through a coding question. An array is monotonic if it is either monotone increasing or monotone decreasing. if it is, then print true. e.g Input: [1,2,2,3] Output: true
Input: [6,5,4,4] Output: true
Input: [1,3,2] Output: false
Now, problem is how to handle this input using Scanner? Do I need to take it as String and then remove with some tricks or there is better way to take input like above?
I saw a result here in C++
but it does not helped me. How can I do it. Any help is appreciated.
Note: I do not need the solved code for this problem. Rather i'm interested in how to take above array as input.