Skip to content

Instantly share code, notes, and snippets.

@sagnikc395
Created December 19, 2023 04:05
Show Gist options
  • Save sagnikc395/ecb01ae2127e055c597f1654e591bd6c to your computer and use it in GitHub Desktop.
Save sagnikc395/ecb01ae2127e055c597f1654e591bd6c to your computer and use it in GitHub Desktop.
check if a array of numbers is a bitonic sequence cassidoo interview ques #331
const isBitonic = (arr: number[]):boolean => {
let left = 0;
let right = 0;
for(let i=0;i<arr.length-1;i++){
left = arr[i];
right = arr[i+1];
if(right<left){
console.log(left);
return true;
}
}
return false;
}
console.log(isBitonic([1,2,3,1]));
console.log(isBitonic([1,2,3]));
console.log(isBitonic([3,4,5,5,5,2,1]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment