Lassi
bruteCoder
java
2 years ago
537 B
10
Indexable
class Solution {
public boolean countSub(long arr[], long n)
{
// Your code goes here
for(int i = 0 ;i<n;i++){
if(!condiChecker(arr,n,i)) return false;
}
return true;
}
public boolean condiChecker(long arr[],long n , int i){
int left = i*2 +1;
int right = i*2+2;
if(left < n && arr[left] > arr[i]) return false;
if(right < n && arr[right] > arr[i]) return false;
return true;
}
}Editor is loading...
Leave a Comment