Created
December 19, 2023 04:05
check if a array of numbers is a bitonic sequence cassidoo interview ques #331
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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