Is there any other optimize solution for the question

solution for Finding CB Numbers. i already solve this problem but is there any effective solution then these

hello @Jainish-Patel-1007094602980100
this is efficent approach.