Q1) You are given a positive Integer N, your task is to find the next smallest integer greater than N that does not contain two identical consecutive digits
ex: N=1765 -> 1767 beause 1766 has two identical consecutive digits
N=54 -> 56 not 55 because two identical digits
Solved using brute force, could think of an optimal solution.
function sol(N){
while(true){
if(!checkConsecutive(`${N+1}`)){
return N+1;
}
N++
}
}
function checkConsecutive(N){
if(N.length == 1) return false;
let flag = false;
for(let i = 0;i<N.length-1;i++){
if(N[i] === N[i+1]){
flag = true
}
}
return flag
}