# Consecutive 1's in Binary Numbers

# Consecutive 1's in Binary Numbers

+ 0 comments hi

this problem solution can be optimize further. here is the trick to solve this problem in O(K).

+ 2 comments Those who are looking for javascript solution

const n = parseInt(readLine(), 10); let count = 0; let result = 0; let arr = n.toString(2); for(let i = 0; i< arr.length; i++) { if(arr[i] == 0) { count = 0; } else { count++; result = Math.max(result, count) } } console.log(result)

+ 1 comment Stack stack=new Stack(); int count=1,i=-1,max=0; while(n!=0) { stack.push(n%2); n=n/2; } while(!stack.isEmpty()) { if(stack.peek()==i) { count++; }

`if(max<count) { max=count; } i=stack.peek(); if(i==0) { count=1; } stack.pop(); }`

+ 0 comments When we state real estate logos design, we mean a brand mark which has a capacity to impart in the interest of their business to the world. It's anything but a medium-term work for it requires a broad research work about the most recent real estate logo design patterns and contender's image imprint to think of something that is one of a kind, captivating and eye-getting.

+ 0 comments n=int(input("Enter a number: ")) a=[] while(n>0): dig=n%2 a.append(dig) n=n//2 a.reverse() print("Binary Equivalent is: ") for i in a: print(i,end=" ")

Sort 80 Discussions, By:

Please Login in order to post a comment