H
Heyoka955
Gast
For the purposes of this Kata, you may assume that all inputs are valid, i.e. non-empty arrays containing only integers.
Note that an array of 1 integer is automatically considered to be sorted in ascending order since all (zero) adjacent pairs of integers satisfy the condition that the left integer does not exceed the right integer in value. An empty list is considered a degenerate case and therefore will not be tested in this Kata - feel free to raise an Issue if you see such a list being tested.
For example:
isAscOrder(new int[]{1,2,4,7,19}) == true
isAscOrder(new int[]{1,2,3,4,5}) == true
isAscOrder(new int[]{1,6,10,18,2,4,20}) == false
isAscOrder(new int[]{9,8,7,6,5,4,3,2,1}) == false // numbers are in DESCENDng number
ich habe einen Code geschrieben und der funktioniert nicht so ganz kann einer mir helfen
Note that an array of 1 integer is automatically considered to be sorted in ascending order since all (zero) adjacent pairs of integers satisfy the condition that the left integer does not exceed the right integer in value. An empty list is considered a degenerate case and therefore will not be tested in this Kata - feel free to raise an Issue if you see such a list being tested.
For example:
isAscOrder(new int[]{1,2,4,7,19}) == true
isAscOrder(new int[]{1,2,3,4,5}) == true
isAscOrder(new int[]{1,6,10,18,2,4,20}) == false
isAscOrder(new int[]{9,8,7,6,5,4,3,2,1}) == false // numbers are in DESCENDng number
ich habe einen Code geschrieben und der funktioniert nicht so ganz kann einer mir helfen
Java:
public class Solution {
public static boolean isAscOrder(int[] arr) {
if(arr == null) return false;
int count = 0;
for(int i = 0; i < arr.length; i++){
if(arr[i] < arr[i+1]) count ++;
}
if(arr.length-1 == count){ return true; }
return false;
}
}